PHP hidden IP address Two-bit display as an asterisk method, IP asterisk
This example describes the two-bit display of the PHP hidden IP address as an asterisk. Share to everyone for your reference. The implementation method is as follows:
We in many public websites will encounter the display user's IP when the next few IP segments appear as asterisks, so that the user's privacy is well protected, interested friends can come together to see.
PHP is formatting the IP address, hiding the next bit.
Example
Copy the Code code as follows: <?php
Hide the latter one
return Preg_replace ('/(\d+) \. ( \d+) \. (\d+) \. (\d+)/is ', "$1.$2.$3.*", $IP);
Hide IP The last few are *
Echo ereg_replace ("[^\.] {1,3}$ "," * ", $IP);
?>
Example
PHP implements the method of hiding the last or last two paragraphs of an IP address
Copy the Code code as follows: <?php
--Hide 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 "------------------
";
Echo Preg_replace ($reg 2, "$1.$2.*.*", $ip);//The above output is: 127.0.*.*
?>
Example
Copy the Code code as follows: function Suohao ($phone) {
$p = substr ($phone, 0, 3). " ". substr ($phone, 8, 3);
return $p;
}
Of course there are like arrays with. After separating the array 2, 3 to replace it can be or combine 0,1 array.
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/915424.html www.bkjia.com true http://www.bkjia.com/PHPjc/915424.html techarticle php hides the IP address after the two-bit display as an asterisk method, IP asterisk This article describes the PHP hidden IP address after the two-bit display as an asterisk method. Share to everyone for your reference. Concrete implementation of the party ...