foreach ($dives_file as $dives) {
$type = explode(",", $dives);
$divetype = $type[1];
$duration = $type[2];
$depth = $type[3];
}
如何获得所有$duration
个数字的总和?
答案 0 :(得分:0)
请将您的代码更新到下一个:
$duration = 0;
foreach ($dives_file as $dives)
{
$type = explode(",", $dives);
$divetype = $type[1];
$duration += $type[2];
$depth = $type[3];
}