Return to Snippet

Revision: 25660
at August 25, 2010 01:12 by jrobinsonc


Updated Code
$url = "Jose Robinson Blog http://www.joserobinson.com/blog";
$url = preg_replace("#https?://[A-z0-9\./-_+&\#@:%~=]+#", '<a href="$0">$0</a>', $url);

Revision: 25659
at April 5, 2010 08:22 by jrobinsonc


Initial Code
function makeClickableLinks($text) {
 $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
 '<a href="\1">\1</a>', $text);
 $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
 '\1<a href="http://\2">\2</a>', $text);
 $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})',
 '<a href="mailto:\1">\1</a>', $text);

return $text;
}

Initial URL


Initial Description
This function converts URLs and e-mail addresses within a string into clickable hyperlinks.

Initial Title
Convert URLs within String into hyperlinks

Initial Tags


Initial Language
PHP