<?php
// this function shall search for any url that matches the pattern
// like:
// www.mysite.com
// http://www.mysite.com
// http://mysite.com
// those urls shall be replaced by a html link tag
$text= preg_replace('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@', '<a href="$1" target="blank">$1</a>', $text);
//because you want the url to be an external link the href needs to start with 'http://'
//simply replace any occurance of 'href="www.' into 'href="http://www."
$status = str_replace("href=\"www.","href=\"http://www.",$status);