<?php $testOne = array ( 'Smith'=> 98, 'Johnson' => 67, ); $testTwo = array ( 'Smith'=> 100, 'Johnson' => 85, ); $testThree = array ( 'Smith'=> 78, 'Johnson' => 92, ); $testFour = array ( 'Smith'=> 91, 'Johnson' => 88, ); $total = [$testOne, $testTwo, $testThree, $testFour]; Foreach($total[0] as $name => $val){ $averages[$name] = array_sum(array_column($total, $name))/count($total); } var_dump($averages);
You have javascript disabled. You will not be able to edit any code.