dongyuyi5680
2019-06-12 18:31
浏览 40
已采纳

PHP中多维数组的求和值

Supposing I have this array in PHP:

Array
(
    [0] => Array
        (
            [name] => Banana
            [quantity] => 124
        )
    [1] => Array
        (
            [name] => Cherry
            [quantity] => 24
        )
    [2] => Array
        (
            [name] => Apple
            [quantity] => 224
        )

)

How can I sum the number with the key quantity ?

Thanks.

图片转代码服务由CSDN问答提供 功能建议

假设我在PHP中有这个数组:

  Array \  n(
 [0] =>数组
(
 [名称] =>香蕉
 [数量] => 124 
)
 [1] =>数组
(
 [  name] => Cherry 
 [数量] => 24 
)
 [2] =>数组
(
 [名称] => Apple 
 [数量] => 224 
  )
 
)
   
 
 

如何使用密钥 quantity 对数字求和? < p>谢谢。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题