ฟังก์ชั่น แปลงข้อความ www และ email ให้เป็นลิงค์

แบบที่ 1

<?
  $txt = "goragod@yahoo.com";
  $txt = preg_replace('#(.*)\@(.*)\.(.*)#' , '<a href="mailto:\\1@\\2.\\3">Send email</a>',$txt);
  echo $txt;
?>

แบบที่ 2 สำหรับ รายชื่อ email ที่เป็นตัวแรกของบรรทัด

<?
  $txt = preg_replace("#(^[
])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i" , "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $txt );
?>