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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -