Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How php hides intermediate characters

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report