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.