php - Counting the frequency in 100 arrays, want the 6 most frequent numbers to be displayed -


i display 6 frequent numbers out of 100 arrays displayed, far have this:

foreach($lottotickets $i =>$ivalue) {          $counts = array_count_values($tickets);         arsort($counts);         $list = array_keys($counts);         var_dump($list); } 

but shows frequency seperate arrays, not want.

the below code fetch 6 frequent elements among 100 arrays:

$freqarr = array(); foreach($allarrays $array) {    foreach($array $num) {       if(isset($freqarr[$num])) {          $freqarr[$num] += 1;       } else {          $freqarr[$num] = 1;       }    } }  arsort($freqarr); $counts = array_slice($freqarr, 0, 5); $list = array_keys($counts); var_dump($list); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -