How does PHP convert a mailbox to an email address? The following HTMLcode is used for example: email: [email & #160; protected] [email & #160; protected] to mail.163.commail.qq.com: [email & PHP converts email to email address
How can I convert the email address entered by the user into an email address? As follows:
HTML code
For example: mailbox: [email protected] [email protected] to: http://mail.163.com http://mail.qq.com mailbox: [email protected] [email protected] to: http://vip.163.com http://vip.sina.com
Thank you very much.
------ Solution --------------------
$ 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 );
}
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.