: This article mainly introduces the PHP user name, email address, and phone account strings to hide them. if you are interested in the PHP Tutorial, refer to them.
Function hideStar ($ str) {// user name, email address, and phone account string to hide if (strpos ($ str ,'@')) {$ email_array = explode ("@", $ str); $ prevfix = (strlen ($ email_array [0]) <4 )? "": Substr ($ str, 0, 3); // mail prefix $ count = 0; $ str = preg_replace ('/([\ d \ w + _-] {0,100}) @/', '*** @', $ str,-1, $ count); $ rs = $ prevfix. $ str;} else {$ pattern = '/(1 [3458] {1} [0-9]) [0-9] {4} ([0-9] {4})/I '; if (preg_match ($ pattern, $ str )) {$ rs = preg_replace ($ pattern, '$1 ***** $ 2', $ str); // substr_replace ($ name ,'****', 3, 4);} else {$ rs = substr ($ str, 0, 3 ). "***". substr ($ str,-1) ;}return $ rs ;}
The above describes the PHP user name, email address, and phone account strings to hide, including some content, and hope to help those who are interested in PHP tutorials.