假设我有一个数组:
Array
(
[0] => Array
(
[filmType] => Symphony 15%
[rollSize] => 36
[linearFt] => 3
)
[1] => Array
(
[filmType] => Symphony 15%
[rollSize] => 36
[linearFt] => 3
)
[2] => Array
(
[filmType] => Symphony 15%
[rollSize] => 48
[linearFt] => 5
)
[3] => Array
(
[filmType] => Symphony 25%
[rollSize] => 36
[linearFt] => 7
)
[4] => Array
(
[filmType] => Symphony 35%
[rollSize] => 36
[linearFt] => 10
)
[5] => Array
(
[filmType] => Symphony 35%
[rollSize] => 36
[linearFt] => 10
)
怎么可能仅将唯一数组元素的 [linearFt] 相加。唯一我的意思是 [filmtype] 和 [rollSize] 相同。
我尝试了多种方法,包括搜索数组、数组过滤器和 usort ......我是 PHP 新手,这不是家庭作业。谢谢你的帮助!
所以我的输出是:
$totalsArray = Array(
[0] => Array
(
[filmType] => Symphony 15%
[rollSize] => 36
[linearFt] => 8
)
[1] => Array
(
[filmType] => Symphony 15%
[rollSize] => 48
[linearFt] => 3
)
[2] => Array
(
[filmType] => Symphony 25%
[rollSize] => 48
[linearFt] => 7
)
[3] => Array
(
[filmType] => Symphony 35%
[rollSize] => 48
[linearFt] => 20
)