PHP uses asterisks to hide user names, phone and mailbox implementations _php tips

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.