How do I use PHP to add an asterisk to my phone number and name?
On the internet to find a bit, a textbook is not good
http://www.haogongju.net/art/848588
Preg_replace ('/(0[0-9]{2,3}[\-]?[ 2-9]) [0-9]{3,4} ([0-9]{3}[\-]?[ 0-9]?) /I ', ' $1****$2 ', $phone);
I'd like to have my name and phone number (landline 8 or phone 11, the middle part becomes *
------Solution--------------------
PHP code
$tel 1 = "13888111188"; $tel 2 = "+8613888111188"; $tel 3 = "0861088111188"; $tel 4 = "086-010-88111188"; Echo preg_replace ('/(^.*) \d{4} (\d{4}) $/', ' \\1****\\2 ', $tel 1), "\ n"; Echo Preg_replace ('/(^.*) \d{4} (\d{4}) $/', ' \\1****\\2 ', $tel 2), ' \ n '; echo preg_replace ('/(^.*) \d{4} (\d{4}) $/', ' \\1****\ \2 ', $tel 3), "\ n", Echo preg_replace ('/(^.*) \d{4} (\d{4}) $/', ' \\1****\\2 ', $tel 4), "\ n";
------Solution--------------------
PHP code
//mask phone number in the middle Four-bit numeric function Hidtel ($phone) {$IsWhat = Preg_match ('/(0[0-9]{2,3}[\-]?[ 2-9][0-9]{6,7}[\-]? [0-9]?) /I ', $phone); Fixed phone if ($IsWhat = = 1) {return preg_replace ('/(0[0-9]{2,3}[\-]?[ 2-9]) [0-9]{3,4} ([0-9]{3}[\-]?[ 0-9]?) /I ', ' $1****$2 ', $phone); } else {return preg_replace ('/(1[358]{1}[0-9]) [0-9]{4} ([0-9]{4})/I ', ' $1****$2 ', $phone); }}