asadlive84

While Loop -I don't understand.

Jun 7th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. <?php
  2. $headcount=0;
  3. $filpcount=0;
  4.  
  5. while ($headcount<3) {
  6.     $filp=rand(0,1);
  7.     $filpcount++;
  8.    
  9.     if($filp)
  10.     {
  11.         $headcount++;
  12.         echo "<div class=\"coin\">H</div>";
  13.     }
  14.     else
  15.     {
  16.         $headcount=0;
  17.         echo "<div class=\"coin_two\">T</div>";
  18.     }
  19. }
  20. echo "<p class=\"tech\">Itz took {$filpcount} flips</p>";
  21.  
  22.  
  23.  
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment