Posted by Greg Donald on 10/13/05 17:53
On 10/13/05, Bosky, Dave <Dave.Bosky@htcinc.net> wrote:
> Does anyone have a function that will check if an ip address falls with
> a starting/ending ip address range>>
#!/usr/bin/php
<?php
$ip = '10.0.0.1';
$ip2 = '10.0.0.2';
$ip3 = '10.0.0.3';
$ip = abs( ip2long( $ip ) );
$ip2 = abs( ip2long( $ip2 ) );
$ip3 = abs( ip2long( $ip3 ) );
if( $ip2 > $ip && $ip2 < $ip3
|| $ip2 < $ip && $ip2 > $ip3 )
{
echo "In range\n";
}
else
{
echo "Not in range\n";
}
?>
--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/
[Back to original message]
|