I have a scenario that i have to replace after the last point must be replaced with asterisks for the IP address.
Wrong example: 123.456.789
Correct example: 123.456.***
How is this possible?
I have a scenario that i have to replace after the last point must be replaced with asterisks for the IP address.
Wrong example: 123.456.789
Correct example: 123.456.***
How is this possible?
$ip = "XXX.XXX.XXX";
$parts = explode(".", $ip);
if(count($parts) >= 2){
$result = $parts[0].".".$parts[1]."."."***";
}
echo $result;
explode() can be used
$a = '123.456.789';
$b = explode('.', $a);
print_r(str_replace(end($b), '***', $b));