title: PHP recursive function output
body: <p>With the following code: </p>
  
  <pre>
  $array = array(
      'id' => '1',
      'parent_id' => '0',
      'name' => 'top level',
      'children' => array(
          'id' => '2',
          'parent_id' => '1',
          'name' => 'second level',
          'children' => array(
              'id' => '3',
              'parent_id' => '2',
              'name' => 'third level'     
          )
      )
  );
  
  function generateFlatArray($array){
  
    $output .= '[select id="' . $array['id'] . '" name="' . $array['name'] . '"]';
  
    if(is_array($array['children'])){
      generateFlatArray($array['children']);
    }
  
    return $output;
  
  }
  
  print_r(generateFlatArray($array));
  </pre>
  
  <p>Why does this output:</p>
  
  <pre><code>[select id="1" name="top level"]
  </code></pre>
  
  <p>and not what I am expecting, which is:</p>
  
  <pre><code>[select id="1" name="top level"][select id="2" name="second level"][select id="3" name="third level"]
  </code></pre>
  
  <p>I hate recursion. I hate recursion. I hate recursion. Thanks. </p>