In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to hide part of the content of php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Php hide part of the content of the method: 1, create a PHP sample file; 2, through the "function hidestr ($string, $start = 0, $length = 0, $re ='*') {.}" method to achieve hiding.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
How does php hide part of the content?
PHP hides some string functions (such as name, user name, ID card, IP, mobile number, etc.)
The use of this function is almost the same as the PHP built-in function substr (). It's just that substr () is used for interception, while hidestr () is hidden ~
/ * replace the partial character of a string with $re instead of hiding the string to be processed * @ param string $string * @ param int $start specifies where to start the string * positive-start at the specified position of the string * negative-start at the specified position at the end of the string * 0-start at the first character in the string * @ param int $length is optional. Specifies the length of the string to hide. The default is until the end of the string. * positive-hide * negative from the location of the start parameter-hide the string processed by * @ param string $re substitute * @ return string * / function hidestr ($string, $start = 0, $length = 0, $re ='*') {if (empty ($string)) return false; $strarr = array () $mb_strlen = mb_strlen ($string); while ($mb_strlen) {/ / Loop the string into an array $strarr [] = mb_substr ($string, 0,1, 'utf8'); $string = mb_substr ($string, 1, $mb_strlen,' utf8'); $mb_strlen = mb_strlen ($string);} $strlen = count ($strarr); $begin = $start > = 0? $start: ($strlen-abs ($start)) $end = $last = $strlen-1; if ($length > 0) {$end = $begin + $length-1;} elseif ($length
< 0) { $end -= abs($length); } for ($i=$begin; $i= $end || $begin >= $last | | $end > $last) return false; return implode ('', $strarr);} / / hide the middle 4 digits of the mobile phone number ('18600005940 characters, 3,4); / / 186 numbers are reserved only for the last word in the name, which is common with ATM, online banking and other hidestr (' Xie Shiliang', 0,-1) / / * * Show / / hide some email content. Common website accounts, such as Alipay list ($name, $domain) = explode ('@', '979137roomqq.com'); hidestr ($name, 1,-1). @. Hidestr ($domain, 0,2); / / 9****7@**.com "how to hide part of the content" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.