移动应用
958
/** * 隐藏手机号中间4位 * @param $mobile * @return string|string[]|null */ final protected function hideMobilePhoneNumber($mobile) { $IsWhat = preg_match('/(0[0-9]{2,3}[\-]?[2-9][0-9]{6,7}[\-]?[0-9]?)/i', $mobile); if ($IsWhat == 1) { return preg_replace('/(0[0-9]{2,3}[\-]?[2-9])[0-9]{3,4}([0-9]{3}[\-]?[0-9]?)/i', '$1****$2', $mobile); } else { $pattern = '/(\d{3})(\d{4})(\d{4})/i'; $replacement = '$1****$3'; return preg_replace($pattern, $replacement, $mobile); } }