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

藏色散人
Release: 2023-03-09 09:58:02
Original
3852 people have browsed it

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);
Copy after login
//自定义函数手机号隐藏中间四位
function yc_phone($str){
    $str=$str;
    $resstr=substr_replace($str,'****',3,4);
    return $resstr;
}
Copy after login

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>
Copy after login

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template