我开始学习PHP,这可能是一个简单的问题,但我找不到解决方案:( 我已经弄清楚如何计算$ people [0]的总和,但我如何从所有三个数组中得到总值?
$ people [0] = 18.但我如何获得以下总和:$ people [0] + $ people [1] + $ people [2]?
<?php
$people = array(
array(
'name' => "David",
'del1' => "6",
'del2' => "5",
'del3' => "4",
'del4' => "3",
),
array(
'name' => "John",
'del1' => "7",
'del2' => "4",
'del3' => "6",
'del4' => "5",
),
array(
'name' => "Jason",
'del1' => "3",
'del2' => "6",
'del3' => "5",
'del4' => "5",
),
);
function total_sum() {
global $people;
$sum = array_sum($people[0]);
echo $people[0][name]." got ".$sum." points";
}
total_sum();
?>