Get max of each unique key in multidimensional array
我有一个类似于下面的数组。我正在尝试获取数组中每个唯一键的最大权重值,例如商店 A = 230,商店 B = 180,商店 C = 439,品牌密钥也是如此。
1 2 3 4 5 6 7 | Array ( [0] => Array ( [cid] => 123 [weight] => 230 [store] => Store A [brand] => Brand A) [1] => Array ( [cid] => 124 [weight] => 180 [store] => Store B [brand] => Brand B ) [2] => Array ( [cid] => 131 [weight] => 439 [store] => Store C [brand] => Brand B ) [3] => Array ( [cid] => 128 [weight] => 124 [store] => Store B [brand] => Brand B ) [4] => Array ( [cid] => 130 [weight] => 249 [store] => Store C [brand] => Brand C ) ) |
我可以获得整个数组的最大权重值(使用 max(),但需要每个相应键的最大权重。已经搞砸了几个小时,却没有得到任何结果!
任何指针将不胜感激。
1 2 3 4 5 6 7 8 9 |
1 2 3 4 5 6 7 8 9 10 |
在此处查看实际操作:http://codepad.viper-7.com/eF4ZQ7