note 32586 added to function.ip2long
| From: | rbsmith at rack1 dot php dot net | Date: | Sun, 01 Jun 2003 23:29:16 +0000 |
| Subject: | note 32586 added to function.ip2long | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49547@lists.php.net to get a copy of this message | ||
Yet another word on IP_Match here is the complete functions
as described by php-net at dreams4net dot com on 08-Aug-2002 09:31
# determine if an IP address is within
# a particular network with mask
function IP_Match($network, $mask, $ip) {
$ip_long=ip2long($ip);
$network_long=ip2long($network);
$mask_long=ip2long($mask);
if (($ip_long & $mask_long) == $network_long) {
return true;
} else {
return false;
}
}
Thank you, it is simple, fast, and best of all works!
----
Manual Page -- http://www.php.net/manual/en/function.ip2long.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32586
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32586&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32586&report=yes