In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how php replaces asterisks in Chinese". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how php replaces asterisks in Chinese".
Php will replace the asterisk in Chinese: 1, to determine whether the character contains Chinese characters; 2, to use the mb_substr function to replace the specified Chinese part with an asterisk.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How does php replace the asterisk in Chinese?
PHP user names are handled with asterisks
The PHP user name is processed with the * number:
User name: English, Chinese, Chinese and English mixed, Chinese and English characters mixed
The treatment is as follows: the first letter and the end are retained, and the * sign is replaced in the middle (one character is directly displayed, two characters: Zhang *, three or more characters: song * Dan)
First of all, determine whether the character contains Chinese characters, if it is processed by using mb_ series functions (the Chinese here is in UTF-8 format)
UTF-8 Chinese regular: "/ [\ x {4e00} -\ x {9fa5}] + / u"
GB2312 Chinese regular: "/ [" .chr (0xa1). "-" .chr (0xff). "] + /"
/ / determine whether to include the Chinese characters if ("/ [\ x {4e00} -\ x {9fa5}] + / u", $str) {/ / calculate the length $len = mb_strlen ($str, 'UTF-8') according to the Chinese characters; / / echo' Chinese' If ($len > = 3) {/ / three or more characters, with * instead of $str = mb_substr ($str, 0,1, 'UTF-8'). '*'. Mb_substr ($str,-1,1, 'UTF-8');} elseif ($len = = 2) {/ / two characters $str = mb_substr ($str, 0,1,' UTF-8'). Else {/ / calculates the length of $len = strlen ($str) according to the English string; / / echo 'English'; if ($len > = 3) {/ / three or more characters, with * instead of $str = substr ($str, 0,1). '*'. Substr ($str,-1);} elseif ($len = = 2) {/ / two characters $str = substr ($str2, 0,1). '*;}}
Thank you for reading, the above is the content of "how php replaces asterisks in Chinese". After the study of this article, I believe you have a deeper understanding of how php replaces asterisks in Chinese, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.