http://google.com
<a href="http://google.com">http://google.com</a>
$text=preg_replace('#((?:http|https):\/\/[^\s]+)#i','<a href="$1" />$1', $text);
preg_match_all('#((?:http|https):\/\/[^\s]+)#i',$text,$matches); print_r($matches);