I have a list of IP address ranges and I want to create a sequential list of all the IP addresses that the list of ranges contains.
The list is similar to below (but much longer)...
From IP To IP Total IPs Assign Date Owner
1.0.32.0 1.0.63.255 8192 12/4/2011
1.1.16.0 1.1.31.255 4096 12/4/2011
1.1.32.0 1.1.63.255 8192 12/4/2011
1.2.16.0 1.2.31.255 4096 12/4/2011
1.2.32.0 1.2.63.255 8192 12/4/2011
1.2.64.0 1.2.127.255 16384 12/4/2011
1.3.0.0 1.3.255.255 65536 12/4/2011
Currently, I'm repeating the same for ()
loop.
<?php
for ($a = 0; $a <= 255; $a++) {
echo "1.0.32.$a<br>";
}
for ($a = 0; $a <= 255; $a++) {
echo "1.0.33.$a<br>";
}
for ($a = 0; $a <= 255; $a++) {
echo "1.0.34.$a<br>";
}
for ($a = 0; $a <= 255; $a++) {
echo "1.0.35.$a<br>";
}
for ($a = 0; $a <= 255; $a++) {
echo "1.0.36.$a<br>";
}
for ($a = 0; $a <= 255; $a++) {
echo "1.0.37.$a<br>";
}
?>
It spits out a list of IPs, as desired.
1.0.32.0
1.0.32.1
1.0.32.2
1.0.32.3
1.0.32.4
1.0.32.5
1.0.32.6
1.0.32.7
1.0.32.8
This will take me forever, doing it this way. Hehehe...
I'm sure there is some fancy, mathematical, function that would clean that up. I haven't figured it out, though.