Ok, i have some assignment to do with PHP and i would appreciate some assistance. So, let's say i have multidimensional array like this one:
$testarray = array(0 => array(10, 20, 30),
1 => array(50, 60, 70),
2 => array(80, 90, 100),
.
.
.
n => array("", "", "",)
);
Values in array are irrelevant, what matters are array keys. In this case, i have 3 keys in each array element, so when permutation is finished, final result should look like this:
[0] => Array (
[0] => 1 1 1
[1] => 2 1 1
[2] => 3 1 1
[3] => 1 2 1
[4] => 2 2 1
[5] => 3 2 1
[6] => 1 3 1
[7] => 2 3 1
.
.
.
[n] => 3 3 3
)
In case of 4 array keys, final result should look like this:
[0] = Array (
[0] => 1 1 1 1
[1] => 2 1 1 1
[2] => 3 1 1 1
[3] => 4 1 1 1
[4] => 1 2 1 1
.
.
.
[n] => 4 4 4 4
)
I would like to avoid recursion if possible.
Im having problems visualizing the whole looping process and initializing needed variables. I would really appreciate some help. Thank you.