Make links clickable in PhP

A very quick and dirty way of making links clickable in PHP

While i understand ereg may be removed from future versions of PhP? It works currently and probably will for a long time.

So here it is, It will make any link starting with http:// clickable in php generated pages.

1
2
3
4
5
6
<?
$notes = "Hello this is a note, Why not goto http://google.com ?";
$notes = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a target=\"blank\" href=\"\\0\">\\0</a>", $notes); 
echo $notes;
// Will make http://google.com clickable, Works with ftp:// etc:// etc://
?>

Enjoy.