PHP隐藏手机号或邮箱 ```php /** * 隐藏手机号或邮箱 */ function hideStar($str) { //用户名、邮箱、手机账号中间字符串以*隐藏 if (strpos($str, '@')) { $email_array = explode("@", $str); $prevfix = (strlen($email_array[0]) < 4) ? "" : substr($str, 0, 3); //邮箱前缀 $count = 0; $str = preg_replace('/([\d\w+_-]{0,100})@/', '****@', $str, -1, $count); $rs = $prevfix . $str; } else { $rs = substr_replace($str, '****', 3, 4); } return $rs; } ```