foreach($group as $key=>$value) { echo $key. ” = ” .$value. ““; }
例如:
doc1 = 8 doc2 = 7 doc3 = 1
doc1 = 8
doc2 = 7
doc3 = 1
我想计算$ value,所以结果是8 + 7 + 1 =16。我该怎么办?
谢谢。
$sum = 0; foreach($group as $key=>$value) { $sum+= $value; } echo $sum;