Automatically Convert URLs to Links - PHP

Published on Friday, 15th May in Development

You may have been stuck in a situation where you wanted to convert all URLs inside a block of text to clickable links, but to keep already constructed links intact.

Automatically Convert URLs to Links - PHP If you're not too familiar with regex, you might find yourself stuck with getting all URLs converted to clickable links inside a block of text, instead of just passing a single line of string to a function. This small function will do just that - convert all URLs to clickable links.

# make links out of urls
function autolink($string)
{
	$string = preg_replace('$(https?://[a-z0-9_./?=&-]+)(?![^<>]>)$i', ' $1 ', $string." ");
	return $string;
}

Worth Reading

Saturday, 25th Apr in CSS Tutorials

Understanding the Difference Between DIV and SPAN

It can be a bit confusing trying to figure out when to use a span and when to use a division, but this quick tutorial should help to clarify things.

Tuesday, 21st Apr in Development

Google's Mobile Friendly Update

Earlier this year, Google announced that it was making a change to its search algorithms and today they begin rolling out their mobile-friendly update.

From the Archives

Connect

Connect

Fixed-width corporate template featuring large pitch area.