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

css - Text drops down with smaller window -

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

ruby on rails - Authlogic - how to make a registration and don't log in the new account? -