publicfunction autolink($string){$regex='/((http|ftp|https):\/\/[\w-]+(\.[\w-]+)+'.'([\w.,@?^=%&amp;amp;:\/~+#-]*'.'[\w@?^=%&amp;amp;\/~+#-])?)/';// Check if there is a url in the textif(preg_match($regex,$string)){// make the urls hyper links$replace='&lt;a href="\1" target="_blank"&gt;\1&lt;/a&gt; ';$string=preg_replace($regex,$replace,$string);}return$string;}