title: Multi Array From Query
body: <p>I am doing a count and sum on each item, and need the array to look like this.</p>
  
  <pre><code>[Date] =&gt; 
           [device_type1] =&gt; [all the data]
           [device_type2] =&gt; [all the data]
  </code></pre>
  
  <p>Thing is I am doing a search through each and then all of them return a date, I need all of them to be under that one date, and inside that array to hold each of the devices as key and inside that all the information. here is what I have so far.</p>
  
  <pre><code>$all_device_types = array('pole','covert','firewatch','internet','trailer','slave','project');
  foreach ($all_device_types as $adt) {
      $du-&gt;select("CONCAT(YEAR(uptime_date),'-',MONTH(uptime_date),'-',DAY(uptime_date)) as year_month_day,
  
                               SUM(uptime_router) as router,
  
                               COUNT(uptime_router) as router_count,
  
                               uptime_device_type as device_type,
  
                              date(uptime_date) as data_date","
  
                              WHERE uptime_device_type = '".$adt."'
  
                              GROUP BY CONCAT(YEAR(uptime_date),'-',MONTH(uptime_date),'-',DAY(uptime_date))
  
                              ORDER BY uptime_date ASC");
  
  
                              $all_results = array();
                              while( $all_row = $du-&gt;fetch() ){
  
                                  if ($adt == $all_device_types[0]) {
                                      $dates[] = $all_row['data_date'];
                                      $adt_0 = $all_row;
                                  } elseif ($adt == $all_device_types[1]) {
                                      $adt_1[] = $all_row;
                                  } elseif ($adt == $all_device_types[2]) {
                                      $adt_2[] = $all_row;
                                  } elseif ($adt == $all_device_types[3]) {
                                      $adt_3[] = $all_row;
                                  } elseif ($adt == $all_device_types[4]) {
                                      $adt_4[] = $all_row;
                                  } elseif ($adt == $all_device_types[5]) {
                                      $adt_5[] = $all_row;
                                  } elseif ($adt == $all_device_types[6]) {
                                      $adt_6[] = $all_row;
                                  }
  
                              }
  
                          }
  </code></pre>
  
  <p>One of the results looks like this.</p>
  
  <pre><code> [pole] =&gt; Array
          (
              [year_month_day] =&gt; 2017-9-5
              [router] =&gt; 4408
              [router_count] =&gt; 4620
              [device_type] =&gt; pole
              [data_date] =&gt; 2017-09-05
          )
  </code></pre>