Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $votes = array("A","A","B","B");
- $total = count($votes);
- echo "Votes: " . $total . "\n";
- $per_person = array_count_values($votes);
- $most_votes = array_search(max($per_person),$per_person);
- if( max($per_person)/$total > 1/2 )
- {
- echo $most_votes;
- } else {
- echo "No winner!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement