The example in this article describes the two-bit method of displaying an asterisk after PHP hides the IP address. Share to everyone for your reference. The implementation methods are as follows:
We are in a lot of public websites will encounter the user's IP when the next few IP segments appear as asterisks, so good protection of the user's privacy, interested friends can take a look.
PHP is formatted with the IP address, hiding the next bit.
Example
Copy Code code as follows:
<?php
Hide the later one
return Preg_replace ('/(\d+) \. ( \d+) \. (\d+) \. (\d+)/is ', "$1.$2.$3.*", $IP);
Hide IP last few for *
Echo ereg_replace ("[^\.] {1,3}$ "," * ", $IP);
?>
Example
PHP to implement a hidden IP address last paragraph or the last two ways
Copy Code code as follows:
<?php
--Hidden IP after several
$ip = ' 127.0.0.1 ';
$reg 1 = '/((?: \ D+\.) {3}) \d+/';
$reg 2= ' ~ (\d+) \. (\d+) \. (\d+) \. (\d+) ~ ';
Echo preg_replace ($reg 1, "\\1*", $ip);//The above output is: 127.0.0.*
echo "------------------<br/>";
Echo Preg_replace ($reg 2, "$1.$2.*.*", $ip);//The above output is: 127.0.*.*
?>
Example
Copy Code code as follows:
function Suohao ($phone) {
$p = substr ($phone, 0, 3). " ". substr ($phone, 8, 3);
return $p;
}
There are, of course, arrays like the. After separating the array 2, 3 to replace it can be or combined 0,1 array.
I hope this article will help you with your PHP program design.