I need to create a loop that returns all values between the ip range:
0.0.0.0 and 255.255.255.255
I started off like this, but got stuck:
$ipUpper = "255.255.255.255";
$octets = explode(".",$ipUpper);
for($i=$octets[0]; $i==0; $i--) {
...
}
TIA.
<?php for($i=0;$i<256;$i++) { for($j=0;$j<256;$j++) { for($k=0;$k<256;$k++) { for($l=0;$l<256;$l++) { echo $i . '.' . $k. '.' . $j. '.' . $l . '<br />'; } } } } ?>
However this is 2564 strings which is 4,294,967,296 ip addresses.
Beautiful! Thanks a lot.
I realize the size of the output, but I'm working on a script that maps a visitor's ip to his location. A lot of the ip addresses won't have matching locations, hence, I'll the ultimate size would be smaller.
for($i=0; $i<=4294967295; $i++) { echo long2ip($i),"<br />"; }