Advertisement
ujiajah1

whilelooping.php

Aug 20th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>A loop of your own</title>
  5.         <link type='text/css' rel='stylesheet' href='style.css'/>
  6.     </head>
  7.     <body>
  8.     <?php
  9.     $headCount = 0;
  10.     $flipCount = 0;
  11.     while ($headCount < 3) {
  12.         $flip = rand(0,1);
  13.         $flipCount ++;
  14.         if ($flip){
  15.             $headCount ++;
  16.             echo "<div class=\"coin\">H</div>";
  17.         }
  18.         else {
  19.             $headCount = 0;
  20.             echo "<div class=\"coin\">T</div>";
  21.         }
  22.     }
  23.     echo "<p>It took {$flipCount} flips!</p>";
  24.     ?>
  25.     </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement