嗨,对于以下情况,如何从 foreach 循环中获取总和:
price = Array
(
[0] => Array
(
[0] => 100
[1] => 200
)
[1] => Array
(
[0] => 300
[1] => 400
)
)
我怎样才能得到每个元素的平均值和?我需要补充
avg1 = price[0][0] + price[1][0] .... + price[N][0]
avg2 = price[0][1] + price[1][1] .... + price[N][1]
然后除以元素数。谢谢