Sum values in foreach loop php -


foreach($group $key=>$value) {     echo $key. " = " .$value. "<br>"; } 

for example:

doc1 = 8

doc2 = 7

doc3 = 1

i want count $value, result 8+7+1 = 16. should do?

thanks.

$sum = 0; foreach($group $key=>$value) {    $sum+= $value; } echo $sum; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -