Home  >  Article  >  Backend Development  >  留言内容遇到7-11位纯数字,自动隐藏掉其中2位,代码应该如何写

留言内容遇到7-11位纯数字,自动隐藏掉其中2位,代码应该如何写

WBOY
WBOYOriginal
2016-06-13 13:18:28870browse

留言内容遇到7-11位纯数字,自动隐藏掉其中2位,代码应该怎么写?
有些客户留言时,留下了QQ或手机号,不想让竞争对手看到。显示时自动隐藏掉其中2位,代码应该怎么写?

------解决方案--------------------
再给你个邮箱的例子:

PHP code
<?php $str = "你好,我的邮箱是,lisidfie23mk@yahoo.com.cn,请随时和我联系";
$patten = "/(\w+)(\w){2}(@(\w+.)+)/i";
echo preg_replace($patten,"$1**$3",$str); <div class="clear">
                 
              
              
        
            
Statement:
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