Jump to content

Php most common ints in array


bobert5696

Recommended Posts

Here is my situation, I have an array containing say 50 numbers in it ( array(1,2,3,4,5,6,7,8,9,10,etc etc) ) and there will be many duplicates in it. I am trying to return the top ten numbers in it, in order from greatest to least. I can return the most common one, but I need the most common ten. This is what I have tried:

 

$final_results contains an array of numbers [0][10],[1][23],[2][0],[3][5] etc etc

 

array_count_values($final_results) will return the number of times each number is duplicated in a new array, in the form [number][duplications] and it preserves the number

 

Anything I do after that point replaces [number] with [0][1][2] for say the 3 most common if that makes sense

 

Thanks for the help!

Link to comment
https://forums.phpfreaks.com/topic/244978-php-most-common-ints-in-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.