Code: Select all
function addLinks ( $str ) {
$str = preg_replace( "#(http://(?:www\.)?[^\s\.]*\.[^\s$]+)#i" , "<a href=\"$1\" style=\"font-weight: bold;\">$1</a>", $str );
echo preg_replace( "#([^/]www\.[\S$]*)#i" , "<a href=\"http://$1\" style=\"font-weight: bold;\">$1</a>", $str );
}