title: Reset array keys in multidimensional array
body: <p>I've been looking around for a solution to this with no real success. I have a multidimensional array of parents and children with no limits on depth. This is generated from a database but the issue is that the item ID becomes the key using my way of arranging a flat array into a multidimensional array like so:</p>
  
  <pre><code>Array(
  
  [28] =&gt; Array
          (
              [id] =&gt; 28
              [color] =&gt; #ff24e5
              [name] =&gt; Personal
              [parent_id] =&gt; 
              [children] =&gt; Array
                  (
                      [23] =&gt; Array
                          (
                              [id] =&gt; 23
                              [color] =&gt; #41c3a3
                              [name] =&gt; Shopping
                              [parent_id] =&gt; 28
                              [children] =&gt; Array
                                  (
                                      [22] =&gt; Array
                                          (
                                              [id] =&gt; 22
                                              [color] =&gt; #8be32b
                                              [name] =&gt; Deals
                                              [parent_id] =&gt; 23
                                              [children] =&gt; Array
                                                  (
                                                  )
                                          )
                                  )
                          )
  
                      [150] =&gt; Array
                          (
                              [id] =&gt; 150
                              [color] =&gt; #e9a3f0
                              [name] =&gt; Orders
                              [parent_id] =&gt; 28
                              [children] =&gt; Array
                                  (
                                  )
                          )
                  )
          )
  )
  </code></pre>
  
  <p>What I would like, is a function that does the following:</p>
  
  <pre><code>Array (
  [0] =&gt; Array
          (
              [id] =&gt; 28
              [color] =&gt; #ff24e5
              [name] =&gt; Personal
              [parent_id] =&gt; 
              [children] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [id] =&gt; 23
                              [color] =&gt; #41c3a3
                              [name] =&gt; Shopping
                              [parent_id] =&gt; 28
                              [children] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [id] =&gt; 22
                                              [color] =&gt; #8be32b
                                              [name] =&gt; Deals
                                              [user_id] =&gt; 1
                                              [selected] =&gt; 0
                                              [parent_id] =&gt; 23
                                              [children] =&gt; Array
                                                  (
                                                  )
                                          )
                                  )
                          )
  
                      [1] =&gt; Array
                          (
                              [id] =&gt; 150
                              [color] =&gt; #e9a3f0
                              [name] =&gt; Orders
                              [parent_id] =&gt; 28
                              [children] =&gt; Array
                                  (
                                  )
                          )
                  )
          )
  )
  </code></pre>
  
  <p>Essentially reassign keys starting from 0. I've tried numerous methods, but I'm assuming that I need to find a recursive solution and when I tried that, it destroyed my array. I was reading up on the array_walk_recursive() function, but I don't quite know what to do beyond that. Essentially, is there a way to reset numeric keys in a multidimensional array?</p>
  
  <p>Thanks for the help!</p>