Last active
March 27, 2018 22:10
-
-
Save svrnm/3a124d2af18a6726f66e to your computer and use it in GitHub Desktop.
Anonymize IPv4 and IPv6 addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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