PHP 將郵箱轉成郵件地址,該怎麼處理

來源:互聯網
上載者:User
PHP 將郵箱轉成郵件地址
怎麼將使用者填寫的郵箱轉換成郵箱地址啊?如下


HTML code
比如:郵箱: [email protected]                     [email protected]轉換成 :http://mail.163.com           http://mail.qq.com郵箱:[email protected]          [email protected]轉成:http://vip.163.com       http://vip.sina.com


非常感謝

------解決方案--------------------
$str = "[email protected]";
echo getMailServer($str);
function getMailServer($mail) {
if (stripos($mail, 'vip') !== false) {
$pre = '/^[a-z][email protected]/i';
$rep = 'http://vip';
} else {
$pre = '/^[a-z]+@/i';
$rep = 'http://mail.';
}
return preg_replace($pre, $rep, $mail);
}

最好多給幾個例子,如果就你給的例子就這麼寫咯。
正則當然是能不用就不用,不過經過長時間觀察,在這種小東西上,實在沒必要去爭取那一點點效率啥的.
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.