Transparently flatten an array

Viewed 1291

Reading this question Merge and group by several arrays i got the following idea: when working with multilevel arrays, with possibly repeating keys, it would be practical to have a function that would iterate such an array as it were flat, like

foreach(flatten($deepArray) as $key => $val)....

any ideas how to write flatten()? Is there any standard solution?

(note that flatten() cannot simply return a new array because of repeating keys).

2 Answers
Related