PHP methods to hide the IP address of the last one

ASP written a long time ago to use the last one to hide the IP address of the article, which is sometimes in order to protect users' privacy, hides the user's IP address, to achieve similar 222.222.222. * Effect. Now you want to use PHP to implement, it has been tried, in fact, very simple, requiring only two PHP string functions can be achieved. Step a:. "";. "" First, with strripos () function to find the last occurrence Then, substr () function is taken before the last string

  

DOT = strripos $ ($ ip, " . " ;) // find the location of the last occurrence. "" 
$ hide_ip = substr ($ ip, 0 , $ DOT). " *. " ; // output last seen. "" before the string position and add an asterisk 
echo $ hide_ip;

If $ ip = 222.222.222.222, the output is the result: 222.222.222 *.

Guess you like

Origin www.cnblogs.com/68xi/p/11518970.html