note 71956 deleted from function.ip2long by nlopess
| From: | nlopess@php.net | Date: | Tue, 26 Dec 2006 11:22:21 +0000 |
| Subject: | note 71956 deleted from function.ip2long by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-120920@lists.php.net to get a copy of this message | ||
Note Submitter: samb057 at gmail dot com
----
Convert an ipv6 address to an base 10 integer
function ip2long6($ip)
{
if (substr_count($ip, '::'))
{
$ip = str_replace('::', str_repeat(':0000', 8 - substr_count($ip,
':')) . ':', $ip) ;
}
$ip = explode(':', $ip) ;
$r_ip = '' ;
foreach ($ip as $v)
{
$r_ip .= str_pad(base_convert($v, 16, 2), 16, 0, STR_PAD_LEFT) . '<br />' ;
}
return base_convert($r_ip, 2, 10) ;
}