code: public static function anonymizeIp($strIp)
  	{
  		// Localhost
  		if ($strIp == '127.0.0.1' || $strIp == '::1')
  		{
  			return $strIp;
  		}
  
  		// IPv6
  		if (strpos($strIp, ':') !== false)
  		{
  			return substr_replace($strIp, ':0000', strrpos($strIp, ':'));
  		}
  		// IPv4
  		else
  		{
  			return substr_replace($strIp, '.0', strrpos($strIp, '.'));
  		}
  	}
docs: Anonymize an IP address by overriding the last chunk
  
  @param string $strIp The IP address
  
  @return string The encoded IP address