-
-
Save leavyli/41203f8f291db792d079db0c974dd958 to your computer and use it in GitHub Desktop.
替换手机星号
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //输出结果string(115) "mobile: 13929****47,13929****47,13929****47,13929****47,1****3,13929****47,13929****47, name:liwei, moblie: 1****6" | |
| $s = "mobile: 13929571847,13929527847,13929517847,13929575847,123,13929575847,13929575847, name:liwei, moblie: 12636"; | |
| $p =[ | |
| "/(.*?)(\d)(\d{1,4})(\d{1,2},)/", | |
| "/(.*?)(\d)(\d{1,4})(\d{1,2}$)/", | |
| ]; | |
| $r = [ | |
| '\1\2****\4', | |
| '\1\2****\4', | |
| ]; | |
| $res = preg_replace($p, $r, $s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment