OK.
Let me put it this way:
Assuming I have an array ($arr[]), with a varying number of elements (let's use 4 for now), I need to increment the value stored in $arr[0] from 0-255.
When $arr[0] reaches 255 it will need to be given the value 0 and $arr[1] will then be incremented by 1. Execution continues in this manner until $arr[0] = 255, $arr[1] = 255, $arr[2] = 255 & $arr[3] = 255.
Obviously I could nest 4 different for() loops to accomplish this but sometimes the array will have many more elements than would be practical using this method.
Here is the code to do just that altered for running on a webserver. It is very processor/bandwidth intensive so you may want to only run it on a local server.
My use for it will be a command line app so script timeout settings in php.ini will not be a factor.
<?php
for ($a = 0; $a < 256; $a++) {
$arr[3] = $a;
for ($b = 0; $b < 256; $b++) {
$arr[2] = $b;
for ($c = 0; $c < 256; $c++) {
$arr[1] = $c;
for ($d = 0; $d < 256; $d++) {
$arr[0] = $d;
echo $arr[0] . " - " . $arr[1] . " - " . $arr[2] . " - " . $arr[3] ."</br>";
}
}
}
}
?>
R. Bowers