Home >Backend Development >PHP Problem >How to hide the middle four digits of mobile phone number in php

How to hide the middle four digits of mobile phone number in php

藏色散人
藏色散人Original
2021-04-02 09:13:143842browse

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.

How to hide the middle four digits of mobile phone number in php

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:

<span style="font-size:18px;"><volist name="zjd_list" id="vo">
 <p>恭喜用户{$vo.user_id|yc_phone=###}砸金蛋获得奖金{$vo.prize}元</p>
   </volist></span>

[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!

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