title: Multi Series Highchart Data with Multidimensial Array
body: <p>I am trying to get my data array in a format that is used by Highcharts to generate a multi-series chart of the data.</p>
  
  <p>My data array is:</p>
  
  <pre><code>Array ( 
  [answer1] =&gt; Array ( [SubQuestion 1] =&gt; 3 [SubQuestion 2] =&gt; 1 ) 
  [answer2] =&gt; Array ( [SubQuestion 1] =&gt; 2 [SubQuestion 2] =&gt; 2 ) 
  [answer3] =&gt; Array ( [SubQuestion 1] =&gt; 1 [SubQuestion 2] =&gt; 1 ) 
  [answer4] =&gt; Array ( [SubQuestion 1] =&gt; 1 [SubQuestion 2] =&gt; 2 ) 
  [answer5] =&gt; Array ( [SubQuestion 1] =&gt; 0 [SubQuestion 2] =&gt; 1 )
  )
  </code></pre>
  
  <p>I need to get it into this format for Highcharts:</p>
  
  <pre><code>$chartdata = array(
  array("name" =&gt;"SubQuestion 1","data"=&gt;  array(3,2,1,1,0) ),
  array("name" =&gt;"SubQuestion 2","data"=&gt;  array(1,2,1,2,1) )
  );
  </code></pre>
  
  <p>Can anyone please point me in the right direction as to how to iterate through my array to create a new array in the HighCharts format?</p>
  
  <p>Thanks for all the help. I just wanted to close the loop and post the slightly modified version of the correct answer:
          $chartdata = array();
          foreach($series as $key1 => $value1){
              $i=0;
              foreach($value1 as $key2 => $value2){
                  $chartdata[$i]['name'] = $key2;
                  $chartdata[$i]['data'][] = $value2;
                  $i++;
              }
                  }</p>