Home>Article>Backend Development> How to hide the middle four digits of mobile phone number in php
php method to hide the middle four digits of the mobile phone number: 1. Hide the middle four digits of the mobile phone number through the "substr_replace($num,'****',3,4);" method; 2. By automatically Just define the "yc_phone" function to hide the middle four digits.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
php method hides the middle four digits of the mobile phone number
$num = "13966778888" $str = substr_replace($num,'****',3,4);
//自定义函数手机号隐藏中间四位 function yc_phone($str){ $str=$str; $resstr=substr_replace($str,'****',3,4); return $resstr; }
Usage in thinkphp template:
恭喜用户{$vo.user_id|yc_phone=###}砸金蛋获得奖金{$vo.prize}元
[Recommended learning:PHP video tutorial]
The above is the detailed content of How to hide the middle four digits of mobile phone number in php. For more information, please follow other related articles on the PHP Chinese website!