PHP实现手机号码中间四位数替换成星号* |
您所在的位置:网站首页 › 南京移动号码中间四位数 › PHP实现手机号码中间四位数替换成星号* |
PHP实现手机号码中间四位数替换成星号*
示例: 字符串截取法直线导轨滑台 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; }posted on 2020-05-04 14:39 佰草伐 阅读(703) 评论(0) 编辑 收藏 举报 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |