$val){ if($val != $maxVote){ break; } else { $voteBox2[] = $key; } } arsort($voteBox2); $ans = current($voteBox2); echo $ans;