score:1

Accepted answer
$myarray = Array ( 
'answer1' => Array ( 'SubQuestion 1'=> 3 , 'SubQuestion 2' => 1 ) ,
'answer2'=> Array ( 'SubQuestion 1' => 2, 'SubQuestion 2' => 2 ) ,
'answer3' => Array ( 'SubQuestion 1' => 1, 'SubQuestion 2' => 1 ) ,
'answer4' => Array ( 'SubQuestion 1' => 1, 'SubQuestion 2' => 2 ) ,
'answer5' => Array ( 'SubQuestion 1' => 0, 'SubQuestion 2' => 1 )
);


$temp = array();
$chartdata = array();
foreach($myarray as $key1 => $value1){
  foreach($value1 as $key2 => $value2){
   if(!in_array($key2, $temp)){
    $temp[] = $key2;
   }
   $chartdata[array_search($key2, $temp)]['name'] = $key2;
   $chartdata[array_search($key2, $temp)]['data'][] = $value2;
  }
}
echo '<pre>';
print_r($chartdata);

Related Query

More Query from same tag