Generating a range of IP address
| From: | rdkurth at starband dot net | Date: | Thu, 23 Jan 2003 04:10:05 +0000 |
| Subject: | Generating a range of IP address | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-132735@lists.php.net to get a copy of this message | ||
I need a way to add a range of IPaddress to a databases the
example below work as long as the last numbers in the IPaddress
are equal length like three numbers or two or one. If the first
IPaddress has 1 number and the second has two or three numbers the
script will not work.
$ip1=230.234.234.4 This will work
$ip2=230.234.234.9
$ip1=230.234.234.4 This will not work
$ip2=230.234.234.25
$ip1=230.234.234.25 This will not work
$ip2=230.234.234.126
$ip1=trim($ip1);
$ip2=trim($ip2);
$ip = $ip1;
while ($ip <= $ip2){
$query = "insert into ipaddress(ip)values ('$ip')";
$Result = safe_query($query);
$ip++;
}
--
Best regards,
rdkurth mailto:rdkurth@starband.net