note 47341 added to function.ip2long
| From: | daevid at daevid dot com | Date: | Fri, 12 Nov 2004 03:30:17 +0000 |
| Subject: | note 47341 added to function.ip2long | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80424@lists.php.net to get a copy of this message | ||
This seems obvious in hindsight, but since nobody else posted it, it had me and two others
scratching our heads. Thought I'd save someone else the trouble...
In mySQL, you can use the INET_ATON() function, but to save queries, you could use this function.
However, the catch is that PHP returns negative values, so you have to use it like this:
$LongIP = sprintf('%u', ip2long($dotted_name));
----
Manual Page -- http://www.php.net/manual/en/function.ip2long.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47341
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47341&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47341&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47341&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47341&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47341&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47341&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47341&report=yes
Search -- http://master.php.net/manage/user-notes.php