darkus
05-16-2010, 04:53 PM
I have a large dynamically created array arranged as follows
[9693] => 2
[9658] => 41
[9654] => 42
[9640] => 24
[9634] => 4
[9613] => 29
[9624] => 433
[9620] => 5
The values (2, 41, 42, 24, etc..) are the # of items associated with the key (9693, 9658, 9654, etc...).
What I want to do is maintain the same order but cut the array down to only the top 3 items in this array based on the values (ie. the number of items associated with that key).
so that my final array would look like this
[9658] => 41
[9654] => 42
[9624] => 433
Does anyone have any clue how to tackle this one?
Thanks!!
[9693] => 2
[9658] => 41
[9654] => 42
[9640] => 24
[9634] => 4
[9613] => 29
[9624] => 433
[9620] => 5
The values (2, 41, 42, 24, etc..) are the # of items associated with the key (9693, 9658, 9654, etc...).
What I want to do is maintain the same order but cut the array down to only the top 3 items in this array based on the values (ie. the number of items associated with that key).
so that my final array would look like this
[9658] => 41
[9654] => 42
[9624] => 433
Does anyone have any clue how to tackle this one?
Thanks!!