当前位置: 代码迷 >> PHP >> 将信箱的某一段替换为
  详细解决方案

将信箱的某一段替换为

热度:42   发布时间:2016-04-28 19:34:49.0
将邮箱的某一段替换为*
将邮箱地址的第3 位到'@'之间的字符串替换为符号'*'   谢谢
------解决方案--------------------
echo preg_replace('/(?<=.{3}).+@/', '*@', [email protected]');
[email protected]
------解决方案--------------------
$str ="[email protected]";
$sub = substr($str, 2,strpos($str,'@') -2);
$len = strlen($sub);
$replaceStr = str_repeat('*',$len);
$newStr = str_replace($sub, $replaceStr, $str);
var_dump($newStr);
  相关解决方案