foreach($group as $key=>$value)
{
echo $key. " = " .$value. "<br>";
}
例如:
文档 1 = 8
文档 2 = 7
doc3 = 1
我想计算$value,所以结果是8+7+1 = 16.我该怎么办?
I want to count $value, so the result is 8+7+1 = 16. What should i do?
谢谢.
$sum = 0;
foreach($group as $key=>$value)
{
$sum+= $value;
}
echo $sum;
这篇关于在foreach循环php中求和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!