Home >php教程 >PHP源码 >PHP使用星号替代用户名手机和邮箱

PHP使用星号替代用户名手机和邮箱

WBOY
WBOYOriginal
2016-06-08 17:19:511332browse

PHP使用星号替代用户名手机和邮箱这个在许多的活动界面会看到如淘宝的购物界面中的一些客户的支付宝号都是隐藏掉的哦,下面我们来看一下它的使用方法吧。

<script>ec(2);</script>

function hideStar($str) { //用户名、邮箱、手机账号中间字符串以*隐藏
    if (strpos($str, '@')) {
        $email_array = explode("@", $str);
        $prevfix = (strlen($email_array[0])         $count = 0;
        $str = preg_replace('/([\d\w+_-]{0,100})@/', '***@', $str, -1, $count);
        $rs = $prevfix . $str;
    } else {
        $pattern = '/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i';
        if (preg_match($pattern, $str)) {
            $rs = preg_replace($pattern, '$1****$2', $str); // substr_replace($name,'****',3,4);
        } else {
            $rs = substr($str, 0, 3) . "***" . substr($str, -1);
        }
    }
    return $rs;
}
?>

$account = "111cn.net";
$email = "416148489@qq.com";
$phone = "18005152525";
?>


   


       
        演示:PHP以星号隐藏用户名手机和邮箱
       
       
       
   
   
       

           

               
               
           

       

       

           

               

教程:PHP以星号隐藏用户名手机和邮箱

               


                   
                       
                       
                       
                   
                   
                       
                       
                       
                   
                   
                       
                       
                       
                   
               
账号 邮箱 手机

           

       

      
   
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