gpt4 book ai didi

php - 如何在php中对同一个数组求和

转载 作者:行者123 更新时间:2023-12-03 19:53:12 25 4
gpt4 key购买 nike

<分区>

我想对相同键和不同值的数组求和。

Array
(
0 => Array
(
'locker_id' => 3,
'locker_model' => 1,
'qty' => 2
),

1 => Array
(
'locker_id' => 3,
'locker_model' => 1,
'qty' => 1
),

2 => Array
(
'locker_id' => 2,
'locker_model' => 1,
'qty' => 2
),

3 => Array
(
'locker_id' => 3,
'locker_model' => 1,
'qty' => 2
),
4 => Array
(
'locker_id' => 2,
'locker_model' => 1,
'qty' => 2
)

);

我要输出它

Array
(
0 => Array
(
'locker_id' => 3,
'locker_model' => 1,
'qty' => 5
),
1 => Array
(
'locker_id' => 2,
'locker_model' => 1,
'qty' => 4
)
);

谢谢。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com