Skip to content

Instantly share code, notes, and snippets.

@svrnm
Last active March 27, 2018 22:10
Show Gist options
  • Save svrnm/3a124d2af18a6726f66e to your computer and use it in GitHub Desktop.
Save svrnm/3a124d2af18a6726f66e to your computer and use it in GitHub Desktop.
Anonymize IPv4 and IPv6 addresses
<?php
function anonymize_ip($ip) {
if($ip = @inet_pton($ip)) {
return inet_ntop(substr($ip, 0, strlen($ip)/2) . str_repeat( chr(0), strlen($ip)/2 ));
}
return '0.0.0.0';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment