The two lines below are where $ip is the compressed IPv6 address. Returns the extended $ip .
An example :
$ip = "fe80:01::af0"; echo expand($ip);
Function
function expand($ip){ $hex = unpack("H*hex", inet_pton($ip)); $ip = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1); return $ip; }
Mike Mackintosh Aug 23 2018-12-12T00: 00Z
source share