php getting sum from foreach loop

hyyuye3puy

New Member
Hi how is it possible to get sum from foreach loop for the following case:\[code\]price = Array( [0] => Array ( [0] => 100 [1] => 200 ) [1] => Array ( [0] => 300 [1] => 400 ))\[/code\]how can i get average value sum of each elements? i need to add \[code\]avg1 = price[0][0] + price[1][0] .... + price[N][0]avg2 = price[0][1] + price[1][1] .... + price[N][1]\[/code\]then divide by num of elements. Thanks
 
Back
Top