Home > Backend Development > PHP Tutorial > 将信箱的某一段替换为

将信箱的某一段替换为

WBOY
Release: 2016-06-13 11:51:47
Original
892 people have browsed it

将邮箱的某一段替换为*
将邮箱地址的第3 位到'@'之间的字符串替换为符号'*'   谢谢
------解决方案--------------------

echo preg_replace('/(?<=.{3}).+@/', '*@', [email&#160;protected]');
Copy after login
[email protected]
------解决方案--------------------
$str ="[email&#160;protected]";<br />$sub = substr($str, 2,strpos($str,'@') -2);<br />$len = strlen($sub);<br />$replaceStr = str_repeat('*',$len);<br />$newStr = str_replace($sub, $replaceStr, $str);<br />var_dump($newStr);
Copy after login

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template