<?php
$results = [
['name' => '田中', 'japanese' => 83, 'math' => 57, 'science' => 43, 'social' => 72, 'english' => 78],
['name' => '渡部', 'japanese' => 62, 'math' => 88, 'science' => 70, 'social' => 66, 'english' => 38],
['name' => '品川', 'japanese' => 23, 'math' => 33, 'science' => 53, 'social' => 17, 'english' => 7],
['name' => '滝谷', 'japanese' => 93, 'math' => 89, 'science' => 79, 'social' => 96, 'english' => 91],
['name' => '川原田','japanese' => 55, 'math' => 56, 'science' => 60, 'social' => 54, 'english' => 66],
['name' => '一色', 'japanese' => 27, 'math' => 47, 'science' => 100, 'social' => 42, 'english' => 38],
];
function cube($n){
return ['name' => $n['name'].'さん ','total' => ($n['japanese'] + $n['math'] + $n['science'] + $n['social'] + $n['english']).'点'];
}
$output_peaple = array_map('cube', $results);
$menu = array_reduce($output_peaple, function($accumulator, $item){
$index = $item['name'];
$accumulator[$index] = $item['total'];
return $accumulator;
}, []);
arsort($menu);
$cnt = 1;
foreach ($menu as $key => $value){
echo $cnt++.'位:'.$key.$value.PHP_EOL;
}