I have an array similar to the below. I am trying to get the max weight value for each unique key in the array e.g. Store A = 230, Store B = 180, Store C = 439, and the same for the brand key.
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 )
)
I can get the max weight value of the entire array (using max(), but need the max weight for each respective key. Been messing with this for hours and not getting anywhere!
Any pointers would be appreciated.
1 Answer