Return to Snippet

Revision: 60463
at November 9, 2012 20:56 by Hexahow


Initial Code
<?php

function ip62long($ipv6){
	$ip_n = inet_pton($ipv6);
	$bits = 15;

    $ipv6long = 0;

	while($bits >= 0){
		$bin = sprintf("%08b",(ord($ip_n[$bits])));

		if($ipv6long){
			$ipv6long = $bin . $ipv6long;
		}
		else{
			$ipv6long = $bin;
		}
		$bits--;
	}
	return gmp_strval(gmp_init($ipv6long, 2), 10);
}

?>

Initial URL
http://www.ip2location.com/free/ipv6

Initial Description
/********************************************************************************/
/* Description: Calculate and Convert IPV6 to Decimal. */
/* For information, please visit http://www.ip2location.com        */
/********************************************************************************/
/* You can obtain free IPV6 database at http://www.ip2location.com/free/ipv6 */

Initial Title
Calculate and Convert IPv6 to Decimal

Initial Tags

                                

Initial Language
PHP