How does php replace 13412343312 with 134 ** 3312 php replace 13412343312 with 134?
** 3312
Reply content:
How does php replace 13412343312 with 134?** 3312
To be honest, I just learned PHP on the first day... Do you mean to get the first 3 and last 4 digits of the mobile phone number?
Substr_replace ('123', '**', 13412343312 );
Common character hiding
// Function hidecard ($ cardnum, $ type = 1, $ default = "") {if (empty ($ cardnum) {return $ default ;} if ($ type = 1) {$ cardnum = substr ($ cardnum, 0, 3 ). str_repeat ("*", 12 ). substr ($ cardnum, strlen ($ cardnum)-4); // ID} elseif ($ type = 2) {$ cardnum = substr ($ cardnum ). str_repeat ("*", 5 ). substr ($ cardnum, strlen ($ cardnum)-4); // mobile phone number} elseif ($ type = 3) {$ cardnum = str_repeat ("*", strlen ($ cardnum)-4 ). substr ($ cardnum, strlen ($ cardnum)-4); // bank card} elseif ($ type = 4) {$ cardnum = substr ($ cardnum, 0, 3 ). str_repeat ("*", strlen ($ cardnum)-3); // username} elseif ($ type = 5) {$ cardnum = substr ($ cardnum, 0, 3 ). str_repeat ("*", 3 ). substr ($ cardnum, strlen ($ cardnum)-3); // New username} return $ cardnum ;}
13412343312134 *** 3312 echo substr_replace ('20140901', ***** ', 3, 4 ); 3 indicates the number of characters starting with replacement (starting from 0 ). 4 indicates the number of characters to replace.
I:substr_replace
II:preg_replace
Just check the documents separately.
Isn't that a replacement? Substr_replace
String replacement...