PHP 将邮箱转成邮件地址,该怎么处理
Jun 13, 2016 pm 01:37 PM
com
http
mail
php
vip
PHP 将邮箱转成邮件地址
怎么将用户填写的邮箱转换成邮箱地址啊?如下
- HTML code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> 比如: 邮箱: php@163.com php@qq.com 转换成 :http://mail.163.com http://mail.qq.com 邮箱:php@vip.163.com php@vip.sina.com 转成:http://vip.163.com http://vip.sina.com
Copy after login
非常感谢
------解决方案--------------------
$str = "php@vip.163.com";
echo getMailServer($str);
function getMailServer($mail) {
if (stripos($mail, 'vip') !== false) {
$pre = '/^[a-z]+@vip/i';
$rep = 'http://vip';
} else {
$pre = '/^[a-z]+@/i';
$rep = 'http://mail.';
}
return preg_replace($pre, $rep, $mail);
}
最好多给几个例子,如果就你给的例子就这么写咯。
正则当然是能不用就不用,不过经过长时间观察,在这种小东西上,实在没必要去争取那一点点效率啥的.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
