In Ipv4 we can use ip2long
to convert it to number,
How to convert ipv6 compressed to number in PHP?
I tried inet_pton and it\'s not working.
<
Try this
function inet6_to_int64($addr)
{
/* Expand the address if necessary */
if (strlen($addr) != 39) {
$addr = inet6_expand($addr);
if ($addr == false) return false;
} // if
$addr = str_replace(':', '', $addr);
$p1 = '0x' . substr($addr, 0, 16);
$p2 = '0x' . substr($addr, 16);
$p1 = gmp_init($p1);
$p2 = gmp_init($p2);
$result = array(gmp_strval($p1), gmp_strval($p2));
return $result;
} // inet6_to_int64()
For more functions or details please visit http://www.soucy.org/project/inet6/