Converting a URL to a clickable hyperlink

Ask a question






With regular expressions, it is possible to transform any hyperlink URL of the form

http://URL (or ftp://URL) or beginning with www. :

<?
$message = eregi_replace("((([ftp://])|(http(s?)://))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*))","<a href = '\\0' target='_blank'>\\0</a>",$message);

$message = eregi_replace("(([^/])www\.|(^www\.))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*)","\\2<a href = 'http://www.\\4' target='_blank'>www.\\4</a>",$message);
?>

Conditional Hyphenation HTML
Adjust Your Website to Fit All Resolutions