title: Count elements in adjacent array
body: <p>I have an array that has a hierarchic structure. In this example there are two elements in the first level, 83 and 82. 82 has children 84 and 87 . 87 is a child of 84. </p>
  
  <pre><code>Array
  (
  [_children] =&gt; Array
      (
          [0] =&gt; Array
              (
                  [id] =&gt; 11
                  [uid] =&gt; 24
                  [rid] =&gt; 83
                  [date] =&gt; 2011-06-18 15:08:10
              )
  
          [1] =&gt; Array
              (
                  [id] =&gt; 10
                  [uid] =&gt; 24
                  [rid] =&gt; 82
                  [date] =&gt; 2011-06-18 15:08:07
                  [_children] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; 12
                                  [uid] =&gt; 82
                                  [rid] =&gt; 84
                                  [date] =&gt; 2011-06-18 15:30:34
                                  [_children] =&gt; Array
                                      (
                                          [0] =&gt; Array
                                              (
                                                  [id] =&gt; 13
                                                  [uid] =&gt; 84
                                                  [rid] =&gt; 87
                                                  [date] =&gt; 2011-06-18 16:11:50
                                              )
  
                                      )
  
                              )
  
                      )
  
              )
  
      )
  
  )
  </code></pre>
  
  <p>I want to loop through that array and store some information for each level in another array.  This is how my array should look like at the end.</p>
  
  <pre><code> Array
      (  
        [0] =&gt; Array
        (
             [elements] =&gt; 2
        )
  
       [1] =&gt; Array
        (
             [elements] =&gt; 1
        )
  
      )
  </code></pre>
  
  <p>E.g. this shows that at level 0 are 3 nodes and at level 1 there are 5 nodes. How can I do that? Any ideas?</p>