note 107257 modified in function.long2ip by danbrown
| From: | danbrown@php.net | 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 <?php function
convertIpToString($ip) { $long = 4294967295 - ($ip -
1); return long2ip(-$long); }
function convertIpToLong($ip) { return
sprintf("%u", ip2long($ip)); } ?>
--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