Code: Select all
<?php
$text = "What's up man this is the link to the page: http://google.com";
if (ereg('^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$',$text)) {
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $text);
}
echo "$text";
?>