php方法 隐藏手机号中间四位
php自带函数可以实现-substr_replace() 函数
* */
//自定义函数手机号隐藏中间四位
function yc_phone($str){
$str=$str;
$resstr=substr_replace($str,'****',3,4);
return $resstr;
}
语法
substr_replace(string,replacement,start,length)
参数 描述 string 必需。规定要检查的字符串。 replacement 必需。规定要插入的字符串。 start 必需。规定在字符串的何处开始替换。
正数 - 在字符串中的指定位置开始替换
负数 - 在从字符串结尾的指定位置开始替换
0 - 在字符串中的第一个字符处开始替换
length 可选。规定要替换多少个字符。默认是与字符串长度相同。
正数 - 被替换的字符串长度
负数 - 表示待替换的子字符串结尾处距离 string 末端的字符个数。
0 - 插入而非替换