Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>A loop of your own</title>
- <link type='text/css' rel='stylesheet' href='style.css'/>
- </head>
- <body>
- <?php
- $headCount = 0;
- $flipCount = 0;
- while ($headCount < 3) {
- $flip = rand(0,1);
- $flipCount ++;
- if ($flip){
- $headCount ++;
- echo "<div class=\"coin\">H</div>";
- }
- else {
- $headCount = 0;
- echo "<div class=\"coin\">T</div>";
- }
- }
- echo "<p>It took {$flipCount} flips!</p>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement