I want an multidimensional array, where each element is an array of X elements - lets say 3.
I basically want to count from 0 to y (lets say 12) in the 3rd element, then after 0,0,12 I want the next element in the array to be the array 0,1,0 - finished with 12,12,12.
I'm sort of counting up in base...12, ticking over to the next element in the array when it's done.
e.g.
0,0,0
0,0,1
...
0,0,12
0,1,0
0,1,1
0,1,2
...
0,1,12
0,2,0
...
12,12,12
ok, fine - I can do that like this
$maxCountNumber= 12;
$i=1;
for ($j=0; $j < $maxCountNumber+1; $j++) {
for ($k=0; $k < $maxCountNumber+1; $k++) {
for ($l=0; $l < $maxCountNumber+1; $l++) {
print "<br/>$i: $j, $k, $l";
$results[$i] = array($j, $k, $l);
$i++;
}
}
}
But what if I don't want just 3 elements every-time - sometimes i'll want 4 - Rather than hundreds, tens and units I want Thousands, Hundreds, tens and units... or how about 7 elements?
I'm sure recursion is the answer but I just can't seem to bend my head around this particular problem.
Unless there's something that will count up for me in 12s rather than 10s?
Thank you for all and any advice.