Posted by tg-php on 10/13/05 18:38
You could try converting to long IP addresses and comparing that way:
<?php
// To actually get the long IP address that you can use in http://
// you sometimes need to use something like printf("%u\n", ip2long($ip));
// See also: http://us3.php.net/manual/en/function.ip2long.php
$startip = "192.168.0.5";
$endip = "192.168.0.16";
$targetip = "192.168.0.7";
$startlong = ip2long($startip);
$endlong = ip2long($endip);
$targetlong = ip2long($targetip);
if ($startlong <= $targetlong AND $targetlong <= $endlong)
echo "within range";
else
echo "out of range";
?>
= = = Original message = = =
Does anyone have a function that will check if an ip address falls with
a starting/ending ip address range>>
Thanks,
Dave
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
[Back to original message]
|