PHP converts an email address to an email address. how can this problem be solved?

Source: Internet
Author: User
How does PHP convert a mailbox to an email address? The following HTMLcode for example: mailbox: php@163.comphp @ qq.com converted to: mail.163.commail.qq.com mailbox: php@vip.163.com PHP to mail address
How can I convert the email address entered by the user into an email address? As follows:


HTML code
  For example: mailbox: php@163.com php@qq.com into: http://mail.163.com http://mail.qq.com mailbox: php@vip.163.com php@vip.sina.com into: http://vip.163.com http://vip.sina.com


Thank you very much.

------ Solution --------------------
$ 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 );
}

We 'd better give you a few more examples. if you give the example, write it like this.
Regular expressions are not needed, but after a long period of observation, there is no need to strive for efficiency in such a small thing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.