Advertisement
cdsatrian

hitung jawaban

Jul 8th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. $hasil=array();
  3. //$jawaban=$_POST['jawaban'];
  4. $jawaban=array('A','B','A','B','C','D','A','D','C','B','C','D','A');
  5. for($i=0;$i<count($jawaban);$i++){
  6.   $ada=0;
  7.   for($j=0;$j<count($hasil);$j++){
  8.     if($jawaban[$i]==$hasil[$j][1]){
  9.       $hasil[$j][0]++;
  10.       $ada=1;
  11.     }
  12.   }
  13.   if($ada==0){
  14.     $hasil[]=array(1,$jawaban[$i]);
  15.   }
  16. }
  17. for($i=0;$i<count($hasil);$i++){
  18.   echo "jawaban ".$hasil[$i][1]."=".$hasil[$i][0]."<br/>";
  19. }
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement