Anonymize IP Addresses
В редакторе
Anonymize IP Addresses
Brain_Script
777
2018-12-11 20:23:52
function anonymize_ip($ip) {
$last_dot = strrpos($ip, '.') + 1;
return substr($ip, 0, $last_dot)
. str_repeat('x', strlen($ip) - $last_dot);
}
echo anonymize_ip('123.45.67.89'); // "123.45.67.xx"
echo anonymize_ip('12.34.56.123'); // "12.34.56.xxx"
function anonymize_ipv6($ip) {
$last_colon = strrpos($ip, ':') + 1;
return substr($ip, 0, $last_colon)
. str_repeat('x', strlen($ip) - $last_colon);
}
Войдите для добавления комментария.