ด้วยการใช้ฟังก์ชั่น preg_replace

<?
  //link (http, www, ftp, email)
  $patterns = array ('#(^|[^\"\']\s)(www|WWW)\.([^\s<>\.]+)\.([^\"\'\s
<>]+)#sm',
    '#(^|[^\"\'=]{1})(http|HTTP|ftp)(s|S)?://([^\s<>\.]+)\.([^\"\'\s\)<>]+)#sm',
    '/([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)/i'
    );
  $replace = array ('\\1<a href="http://\\2.\\3.\\4" target="_blank">\\2.\\3.\\4</a>',
    '\\1<a href="\\2\\3://\\4.\\5" target="_blank">\\2\\3://\\4.\\5</a>',
    '<a href=\"mailto:\\1@\\2\">\\1@\\2</a>'
    );
  $temp = preg_replace($patterns, $replace, $temp);
?>