85.124.99.2
How to hide the last two numbers from IP?
and do this:
86.124.xxx.xxx
Posted it fast
$ip = "85.124.99.2"; $parts = explode('.',$ip); $new_ip = $parts[0].'.'.$parts[1].'.xxx.xxx';
Caution: you must check the length of parts before accessing $ parts [n]
$ip = preg_replace('/\.\d+\.\d+$/', '.xxx.xxx', $ip);
Use the IP address and print only what you want. Not sure, other than what you mean by "do it," other than printing on the screen.
Use this regex.
(?!\d{1,3}\.\d{1,3}\.)\d
Example
137.133.204.130 -> 137.133.***.*** 93.108.72.157 -> 93.108.**.***