Advertisement
ujiajah1

loop

Aug 21st, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. $hitung_kepala = 0;
  2.  
  3. while ($hitung_kepala < 3) {
  4.     $putar  = rand(0,1);
  5.     if ($putar){
  6.         $hitung_kepala ++;
  7.         echo "(kepala) ";
  8.     }
  9.     else {
  10.         $hitung_kepala = 0;
  11.         echo "(buntut) ";
  12.     }
  13. }
  14.  
  15.  
  16. $kondisi = true;
  17. while ( $kondisi == true){
  18.     // tulis pesan di bawah
  19.     echo "Loop sedang jalan!"; 
  20.    
  21.     // untuk mencegah
  22.     // loop tak terbatas
  23.     $kondisi = false;
  24.     echo "\n";
  25. }
  26. echo "Dan loop pun berakhir";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement