note 104164 deleted from function.ip2long by danbrown

From: Date: Tue, 31 May 2011 17:30:30 +0000
Subject: note 104164 deleted from function.ip2long by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180139@lists.php.net to get a copy of this message
Note Submitter: anjo2 ---- There is an error in my last note. <?php function bin2ip($bin) { if(strlen($bin) <= 32) // 32bits (ipv4) return long2ip(base_convert($bin,2,10)); if(strlen($bin) != 128) return false; $pad = 128 - strlen($bin); for ($i = 1; $i <= $pad; $i++) { $bin = "0".$bin; } $bits = 0; while ($bits <= 7) { $bin_part = substr($bin,($bits*16),16); $ipv6 .= dechex(bindec($bin_part)).":"; $bits++; } return inet_ntop(inet_pton(substr($ipv6,0,-1))); } ?>

« previous php.notes (#180139) next »