<?php
//$scores = array("stu1" => 70, "stu2" => 60, "stu3" => 80, "stu4" => 90, "stu5" => 100);
$scores = [
"stu1" => 70,
"stu2" => 60,
"stu3" => 80,
"stu4" => 90,
"stu5" => 100
];
$sum = 0;
foreach($scores as $v){
$sum += $v;
}
echo $sum . "<br/>";
foreach($scores as $k => $v){
echo "$k - $v<br/>";
}
?>
PHP——一维数组遍历
最新推荐文章于 2022-01-02 18:18:32 发布