有些客户留言时,留下了QQ或手机号,不想让竞争对手看到。显示时自动隐藏掉其中2位,代码应该怎么写?
------解决方案--------------------
再给你个邮箱的例子:
- PHP code
<?php $str = "你好,我的邮箱是,lisidfie23mk@yahoo.com.cn,请随时和我联系"; $patten = "/(\w+)(\w){2}(@(\w+.)+)/i"; echo preg_replace($patten,"$1**$3",$str);
<?php $str = "你好,我的邮箱是,lisidfie23mk@yahoo.com.cn,请随时和我联系"; $patten = "/(\w+)(\w){2}(@(\w+.)+)/i"; echo preg_replace($patten,"$1**$3",$str);