Get the App
SLTechnology News&Howtos  ›  Development  › 

How php hides intermediate characters

Shulou Source: shulou.com Published: 2022-06-03 14:15:24 10月13日 Update

This article mainly shows you "php how to hide intermediate characters", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "php how to hide intermediate characters" this article.

1. Hide the middle number through the "function func_substr_replace () {...}" method.

2. Hide the middle through the "function substr_cut ($user_name) {...}" method and replace it with an asterisk.

Example

/ * * hide partial string * # this method is mostly used to hide the middle digits of mobile phone number or ID number and bank card number * / function func_substr_replace ($str, $replacement ='*', $start = 1, $length = 3) {$len = mb_strlen ($str,'utf-8'); if ($len > intval ($start+$length)) {$str1 = mb_substr ($str,0,$start,'utf-8') $str2 = mb_substr ($str,intval ($start+$length), NULL,'utf-8');} else {$str1 = mb_substr ($str,0,1,'utf-8'); $str2 = mb_substr ($str,$len-1,1,'utf-8'); $length = $len- 2;} $new_str = $str1; for ($I = 0; $I < $length; $iTunes +) {$new_str. = $replacement } $new_str. = $str2; return $new_str;} above is all the content of the article "how to hide intermediate characters in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Characters content articles parts numbers methods learning help card numbers strings examples mobile phones mobile phone numbers easy to understand asterisks more organization this method knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux macOS Apple Shulou Technology