我有一个如下所示的数组
Array (
[0]=> Array
(
[employee_num] =>1009
[employee_name] =>Jane Doe
[amount] =>4500.00
)
[1]=> Array
(
[employee_num] =>1009
[employee_name] =>Jane Doe
[amount] =>2500.00
)
[2]=> Array
(
[employee_num] =>1033
[employee_name] =>Test User
[amount] =>3455.50
)
[3]=> Array
(
[employee_num] =>1009
[employee_name] =>Jane Doe
[amount] =>5500.00
)
[4]=> Array
(
[employee_num] =>1033
[employee_name] =>Test User
[amount] =>7500.00
)
)
我想要得到的是一个像下面这样的数组:(每个用户一个条目及其金额值的总和。)我知道我必须使用一个 for-each,但不能真正理解如何合并 [employee_num] 的条目和 [employee_name]。我事先不知道数组中类似条目的数量或其索引。
Array (
[0]=> Array
(
[employee_num] =>1009
[employee_name] =>Jane Doe
[amount] =>12500.00
)
[1]=> Array
(
[employee_num] =>1033
[employee_name] =>Test User
[amount] =>10955.50
)
)
我怎样才能做到这一点?任何人都可以帮忙吗?谢谢。