In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces how php hides the middle characters. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Php hide the middle characters: 1, through the "function func_substr_replace () {...}" method to hide the middle part of the number; 2, through the "function substr_cut ($user_name) {...}" method to hide the middle and replace with an asterisk.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How does php hide intermediate characters?
PHP implements partial character hiding
/ * * 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;} / * retains only the beginning and end characters of the string, and hides the formatted name * / function substr_cut ($user_name) {$strlen = mb_strlen ($user_name, 'utf-8') of * @ param string $user_name name * @ return string instead of * in the middle of the two characters. $firstStr = ucfirst (strtolower (mb_substr ($user_name, 0,3, 'utf-8')); $lastStr = strtolower (substr ($user_name,-3)); if ($strlen = = 2) {$hideStr = str_repeat (' *, strlen ($user_name, 'utf-8')-1); $result = $firstStr. $hideStr;} else {$hideStr = substr (str_repeat ("*", $strlen-6), 0,3); $result = $firstStr. $hideStr. $lastStr;} return $result;} about how to hide intermediate characters in php is shared here. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.