I need to iterate through multidimensional array. But I need to do it complex: iteration must go by levels - at first elements of 1 level, only after them elements of 2 level, after them elements of 3 level, etc.
I can write it myself if I want to, but I need to make sure I'm not reinventing the wheel. Is there any ready implementation of this in PHP?
UPDATE
What code should i provide? It's a theoretical issue. I can provide you an array.. :
Array
(
[lev1_1] => Array
(
[ID] => 3547
[children] => Array
(
[lev2_1] => Array
(
[ID] => 3550
)
[lev2_2] => Array
(
[ID] => 3551
)
)
)
[lev1_2] => Array
(
[ID] => 3547
[children] => Array
(
[lev2_3] => Array
(
[ID] => 3550
[children] => Array
(
[lev3_1] => Array
(
[ID] => 3550
)
[lev3_2] => Array
(
[ID] => 3551
)
)
)
[lev2_4] => Array
(
[ID] => 3551
)
)
)
I need iterate through lev1_x, then lev2_x, then lev3_x