Advertisement
Guest User

Untitled

a guest
Mar 30th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. <?php
  2.  
  3. $votes = array("A","A","B","B");
  4.  
  5. $total = count($votes);
  6.  
  7. echo "Votes: " . $total . "\n";
  8.  
  9.  
  10. $per_person = array_count_values($votes);
  11.  
  12. $most_votes = array_search(max($per_person),$per_person);
  13.  
  14. if( max($per_person)/$total > 1/2 )
  15. {
  16.     echo $most_votes;
  17. } else {
  18.     echo "No winner!";
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement