This example describes how PHP uses asterisks to hide user names, mobile phones, and mailboxes. Share to everyone for your reference, specific as follows:
PHP uses an asterisk instead of a username cell phone and mailbox this in many active interface will see such as Taobao shopping interface of some customers pay name have are hidden Oh, let's take a look at the use of it.
<?php function Hidestar ($STR) {//username, mailbox, cell phone account middle string to * hide if (strpos ($str, ' @ ')) {$email _array = explode ("@", $str
); $prevfix = (strlen ($email _array[0]) < 4)? "": substr ($str, 0, 3);
Mailbox 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;
?> <?php $account = "Jb51.net";
$email = "123456789@qq.com"; $phone = "13888888888";?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
More interested in PHP related content readers can view the site topics: "PHP string (String) Usage summary", "PHP Array" Operation Techniques Encyclopedia, "PHP Basic Grammar Primer", "PHP Operations and Operator Usage Summary", " Introduction to PHP object-oriented programming program, "PHP Network Programming Skills Summary", "Php+mysql Database Operation Introduction" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design.