title: How to easily split results in PHP with a LEFT JOIN mysql query?
body: <p>I have a query in which I am tring to put the results in an array.
  The query returns all data of the two tables: <code>order</code> and <code>orderdetails</code>:</p>
  
  <pre><code>SELECT orders.*, order_details.* FROM `webshop_orders` 
          LEFT JOIN `order_details` 
          ON `orders`.`order_id` = `order_details`.`f_order_id` 
          WHERE `orders`.`f_site_id` = $iSite_id AND `orders`.`order_id` = $iOrder_id;";
  </code></pre>
  
  <p>I am trying to found out how to return this data an put them in an array of the following format:</p>
  
  <pre><code>$aOrders = array(
  0=&gt;array(Orders.parameter1=&gt;value, orders.parameter2=&gt;value, orders.parameter3=&gt;value, 'orderdetails'=&gt;array(
      array(Orderdetails.parameter1=&gt;value, orderdetails.parameter2=&gt;value)));
  </code></pre>
  
  <p>I currently return every result as an associate array and manually split every variable based on its name using 2 key-arrays, but this seems very 'labor-intensive'?</p>
  
  <pre><code>while($aResults = mysql_fetch_assoc($aResult)) { 
      $i++;
      foreach($aResults as $sKey=&gt;$mValue){
          if(in_array($sKey, $aOrderKeys){
              $aOrder[$i][$sKey] = $mValue;
          } else {
              $aOrder[$i]['orderdetails'][$sKey] = $mValue;
          }
      }
  }
  </code></pre>
  
  <p>EDIT: the function above does not take multiple order-details into consideration, but the function is meant as an example!</p>
  
  <p>Is there an easier way or can I use a better query for this?</p>