I'm trying to loop through one array, adding a new level to another array each time. Let me illustrate - variable $arr's values are different each time
$arr = array("1","5","6");
Looping
$index[$arr[0]];
Looping
$index["1"][$arr[1]] // "1" since this key was filled in by the previous loop, continuing with a new key
Looping
$index["1"]["5"][$arr[2]] // same as previous loop
--looped over all $arr's items, done, result is $index["1"]["5"]["6"]--
The problem is I won't know how much values the $arr
array contains. Then, I don't know how to continue from, for example, $index["1"]
when the first value of $arr
has been looped to the next array level (other words: add another key)..
Anyone?