PHP Get multiple highest values from array -


i have script puts bunch of variables (in case random letters through d) array, counts frequency of these variables, finds highest frequency , finds key matches frequency.

$answerlist = array($a1, $a2, $a3, $a4,); $count = array_count_values($answerlist); $high_value = max($count); $high_key = array_search($high_value, $count);  print_r ($high_key); 

however in case there 2 equal highest values, array_search returns first key. there way return both?

this should it:

$high_keys = array_keys($count, $high_value); 

from array_search docs:

if needle found in haystack more once, first matching key returned. return keys matching values, use array_keys() optional search_value parameter instead.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -