title: Looping through array keys with PHP
body: <p>I have an array that has arrays for each of the values. How can I can I loop through each of these nested arrays (or whatever the technical term is).</p>
  
  <p>This is the structure (there can be multiple order_items per order)</p>
  
  <pre><code>Array ( [0] =&gt; 
           Array ( 
              [order_item] =&gt; Array (
                  [id] =&gt; 1
                  [order_id] =&gt; 1
                  [userid] =&gt; 1
                  [item_number] =&gt; 3
                  [itemName] =&gt; Item A
                  [price] =&gt; 1.99
                  [quantity] =&gt; 1
                  [total] =&gt; 1.99
                  [item_status] =&gt; Not Filled
                  [created] =&gt; 2013-06-13 07:42:00
                  [modified] =&gt; 2013-06-13 07:42:00
              ) 
              [order_item] =&gt; Array (
                  [id] =&gt; 2
                  [order_id] =&gt; 1
                  [userid] =&gt; 1
                  [item_number] =&gt; 4
                  [itemName] =&gt; Item B
                  [price] =&gt; 1.99
                  [quantity] =&gt; 1
                  [total] =&gt; 1.99
                  [item_status] =&gt; Not Filled
                  [created] =&gt; 2013-06-13 07:42:00
                  [modified] =&gt; 2013-06-13 07:42:00
                  )   
              [Order] =&gt; Array (
                  [id] =&gt; 1
                  [userid] =&gt; 4
                  [order_status] =&gt; Not Filled
                  [email] =&gt; test@gmail.com
                  [total] =&gt; 1.99
                  [fullName] =&gt; Test
                  [address] =&gt; Test
                  [city] =&gt; Test
                  [state] =&gt; IA
                  [zip] =&gt; 12345
                  [created] =&gt; 2013-06-13 07:42:00
                  [modified] =&gt; 2013-06-13 07:42:00
              ) 
          ) 
       )
  </code></pre>
  
  <p>There can be multiple order_items per order. I am putting these into an excel spreadsheet so I want to add titles for the orders like so</p>
  
  <pre><code>/* new order */
  //this the headings for an order
  id    name     date    etc... 
   1    test      123
  
  //this is for each of the items in the order
  id    item number   quantity   price  etc..
   1     345             2         1.99
   1     456             1         1.00
  
  /* new order */
  //Another order so the headings must be added again
  id    name     date    etc...
   2    test      345
  
  //this is for each of the items in the orders
  id    item number   quantity   price  etc..
   2     345             1         1.00
  </code></pre>
  
  <p>One thing to note is that I'm using a PHP excel export plugin for CakePHP <a href="https://github.com/josegonzalez/CsvView" rel="nofollow">found here</a> where the data to export follows this structure</p>
  
  <pre><code>$data = array(
          //each of these arrays are rows to be inserted into excel
          array('a', 'b', 'c'),
          array(1, 2, 3),
          array('you', 'and', 'me'),
      );
  </code></pre>
  
  <p>Assuming this array of data to be inserted is $order_values and the array I'm pushing it into is $data</p>
  
  <pre><code>$data = array();
  foreach($order_values as $order){
  
      //Order headings go here
      array_push($data, array('Order ID', 'Order total', etc...))
  
      //order data here. There is always only 1 line of order data per order
      array_push($data, $order[Order]['id'], order[Order]['item_number']..);
  
      //order items headings go here
      array_push($data, array('Item number', 'Item Price', etc..));
  
       foreach(){
            array_push($data, /*now add the order items for the specific order*/)
       }
  }
  </code></pre>
  
  <p>How can I accomplish this?</p>