สำหรับลิงค์ที่มี www
<?
$txt = "http://www.localhost/index.php?id=123 ";
$txt = preg_replace('=([^\s]*)(www.)([^\s]*)=' , '<a href="http://\\2\\3" target=\'_new\'>\\1\\2\\3</a>', $txt);
echo $txt;
?>สำหรับลิงค์ www หรือ ftp ที่มี http นำหน้า และเป็น ตัวแรกของบรรทัดเท่านั้น เช่น http://www.xxx.com
$temp = preg_replace("#(^[
])([\w]+?://[^ \"
\t<]*)#is" , "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $temp);สำหรับลิงค์ www หรือ ftp ที่ไม่มี http และเป็น ตัวแรกของบรรทัดเท่านั้น เช่น www.xxx.com
$txt = preg_replace("#(^[
])((wwwftp)\.[^ \"\t
<]*)#is" , "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $txt);