首页  >  文章  >  后端开发  >  将信箱的某一段替换为

将信箱的某一段替换为

WBOY
WBOY原创
2016-06-13 11:51:47832浏览

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

echo preg_replace('/(?<=.{3}).+@/', '*@', [email&#160;protected]');
[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);

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn