private function expandIPv6($ip) { // Convert to in_addr an unpack as hex $hex = strtolower(bin2hex(inet_pton($ip))); // Inject colons return substr(preg_replace('/([a-f0-9]{4})/', '$1:', $hex), 0, -1); }