首页 > 移动平台 > 详细

PHP实现手机号码中间四位数替换成星号*

时间:2020-05-04 16:27:20      阅读:91      评论:0      收藏:0      [点我收藏+]

示例:

字符串截取法直线导轨滑台

1
2
3
4
5
6
7
/**
 * 中间加密 字符串截取法
 */
public static function encryptTel($tel) {
    $new_tel substr($tel, 0, 3).‘****‘.substr($tel, 7);
    return $new_tel;
}

 

替换字符串

1
2
3
4
5
6
7
/**
 * 中间加密 替换字符串的子串
 */
public static function encryptTel($tel) {
    $new_tel = substr_replace($tel‘****‘, 3, 4);
    return $new_tel;
}

 

正则

1
2
3
4
5
6
7
/**
 * 中间加密 用正则
 */
public static function encryptTel($tel) {
    $new_tel = preg_replace(‘/(\d{3})\d{4}(\d{4})/‘‘$1****$2‘$tel);
    return $new_tel;
}

PHP实现手机号码中间四位数替换成星号*

原文:https://www.cnblogs.com/furuihua/p/12826517.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!