I have an associative multi dimensional array as below
$data = array(); $data = Array ( [0] => Array ( [class] => 1styear [branch] => IT [Exam]
Maybe something like this (not tested)?
$newData = []; foreach ($data as $row) { $student = [ 'student name' => $row['student name'], 'Bio' => $row['Bio'] ]; $newData[$row['class']][$row['branch']][$row['exam']][] = $student; }