title: Removing an outer array in php
body: <p>I have some functions that deal with data provided in array format. These functions all do the same job, so I would like to merge them into a single function.</p>
  
  <p>The problem is, each of them receives arrays with different depths: one-, two- and three-dimensional arrays are used and, in some future implementations, even four-dimensional arrays may be used.</p>
  
  <p>In any case, the significant and necessary data are always in the two innermost arrays, so I need to get rid of the outer arrays until I have only the innermost two-levels. 
  My doubt is not simply how to do it, but how to do it elegantly and efficiently, as I find my current method rather clumsy.</p>
  
  <p>Current method:</p>
  
  <pre><code>function add() {
      $data = func_get_args();
      if(count($data)&gt;0) {
          if(is_array($data[0])) {
              if(is_array($data[0][0])) {
                  foreach($data[0] as $row) {
                      $this-&gt;items[] = $row;
                  }
              } else {
                  $this-&gt;items[] = $data[0];
              }
          } else {
              $this-&gt;items[] = $data;
          }
      }
  } 
  </code></pre>
  
  <p>Some use examples:</p>
  
  <pre><code>$list-&gt;add('one', 'two', 'three', 'four', 'five');
  
  $list-&gt;add($data_from_DB_in_array_format);
  
  $list-&gt;add(
      array(
          array('one', 'two', 'three', 'four', 'five'),
          array('six', 'seven', 'eight', 'nine', 'ten')
          )
      );
  
  $list-&gt;add(
      array(
          array(
              array('one', 'two', 'three', 'four', 'five'),
              array('six', 'seven', 'eight', 'nine', 'ten')
              )
          )
      );
  </code></pre>
  
  <p>As the data is recovered via func_get_args(), everything is put inside an extra array.</p>
  
  <p>The result must be something like this:</p>
  
  <pre><code>    array(
          array('one', 'two', 'three', 'four', 'five'),
          array('six', 'seven', 'eight', 'nine', 'ten')
          );
  </code></pre>