title: Transparently flatten an array
body: <p>Reading this question <a href="https://stackoverflow.com/questions/7010756/merge-and-group-by-several-arrays">Merge and group by several arrays</a> 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</p>
  
  <pre><code>foreach(flatten($deepArray) as $key =&gt; $val)....
  </code></pre>
  
  <p>any ideas how to write <code>flatten()</code>? Is there any standard solution?</p>
  
  <p>(note that <code>flatten()</code> cannot simply return a new array because of repeating keys).</p>