title: PHP recursively go through array
body: <p>I have an array looking like this:</p>
  
  <pre><code>$arr = array(
      array(
          'name'  =&gt;  'n1',
          'id'    =&gt;  0,
          'children' =&gt;   array(
                  array(
                      'name'  =&gt;  'n2',
                      'id'    =&gt;  1,
                      'children'  =&gt;  array(
                          array(
                              'name'  =&gt;  'n3',
                              'id'    =&gt;  2,
                              'children'  =&gt;  array(),
                          ),
                          array(
                              'name'  =&gt;  'n4',
                              'id'    =&gt;  3,
                              'children'  =&gt;  array(),
                          ),
                      ),
                  ),
                  array(
                      'name'  =&gt;  'n17',
                      'id'    =&gt;  4,
                      'children'  =&gt;  array(),
                  ),
              ),
          ),
      );
  </code></pre>
  
  <p>but on a bigger scale.</p>
  
  <p>I want to write a php recursive function which receives the id of the searched element as argument and returns the names it went through to get there, for example, for id==4, the result should be:</p>
  
  <p>array('n1', 'n17');</p>