note 107257 modified in function.long2ip by danbrown

From: Date: Thu, 10 May 2012 21:33:35 +0000
Subject: note 107257 modified in function.long2ip by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187906@lists.php.net to get a copy of this message
Use these two functions to convert from and to numbers compatible to MySQLs INET_ATON and INET_NTOA&#13;&#10;&#60;?php&#13;&#10; function convertIpToString($ip)&#13;&#10; {&#13;&#10; $long = 4294967295 - ($ip - 1);&#13;&#10; return long2ip(-$long);&#13;&#10; }&#13;&#10; function convertIpToLong($ip)&#13;&#10; {&#13;&#10; return sprintf(&#34;%u&#34;, ip2long($ip));&#13;&#10; }&#13;&#10;?&#62; --was-- Use these two functions to convert from and to numbers compatible to MySQLs INET_ATON and INET_NTOA <?php function convertIpToString($ip) { $long = 4294967295 - ($ip - 1); return long2ip(-$long); } function convertIpToLong($ip) { return sprintf("%u", ip2long($ip)); } http://php.net/manual/en/function.long2ip.php

« previous php.notes (#187906) next »