留言内容遇到7-11位纯数字,自动隐藏掉其中2位,代码应该怎么写?
有些客户留言时,留下了QQ或手机号,不想让竞争对手看到。显示时自动隐藏掉其中2位,代码应该怎么写?
——解决方案——————–
再给你个邮箱的例子:
- PHP code
<?php$str = "你好,我的邮箱是,[email protected],请随时和我联系";$patten = "/(\w+)(\来4源gaodaimacom搞#代%码*网搞代gaodaima码
w){2}(@(\w+.)+)/i";echo preg_replace($patten,"$1**$3",$str);