title: Get most deeply nested arrays
body: <p>I have heterogenous nested arrays (each contains a mix of scalars and arrays, which also may contain scalars and arrays, and so on recursively). The goal is to extract all arrays with the maximum depth. Note this does not mean extracting arrays at the &quot;bottom&quot; of any given sub-array (local maximums), but the greatest depth over all sub-arrays.</p>
  <p>For example:</p>
  <pre><code>$testArray= array(
      'test1' =&gt; 'SingleValue1',
      'test2' =&gt; 'SingleValue2',
      'test3' =&gt; array(0,1,2),
      'test4' =&gt; array(array(3,4,array(5,6,7)), array(8,9,array(10,11,12)),13,14),
      'test5' =&gt; array(15,16,17, array(18,19,20)),
  );
  </code></pre>
  <p>In this example, the greatest depth any array occurs at is 3, and there are two arrays at that depth:</p>
  <ul>
  <li><code>array(5,6,7)</code></li>
  <li><code>array(10,11,12)</code></li>
  </ul>
  <p>The code should find these two. (The <code>[18,19,20]</code> sub-array is not included, for though it's at the greatest depth in its branch, it's at a lesser depth overall.)</p>
  <p>I'm not sure where to start. I've tried many things: using <code>foreach</code> in recursive functions, etc., but the end result was always nothing, all elements or the last iterated element. How can this problem be approached? Complete solutions aren't needed, just hints on where to start.</p>