How do I fix the infinite loop?


How do I make it not be infinite?

	$roll = true; 
    $rollCount = 0; 
    do {
        $roll = rand (1, 6); 
        switch (6) {
            case 0:
            	echo "<div class=\"coin\">1</div>";
            case 1: 
            	echo "<div class=\"coin\">2</div>";
            case 2:
            	echo "<div class=\"coin\">3</div>";
            case 3: 
            	echo "<div class=\"coin\">4</div>";
            case 4: 
            	echo "<div class=\"coin\">5</div>";
            case 5: 
            	echo "<div class=\"coin\">6</div>";
        $verb = "were";
        $last = "rolls"; 
        if ($rollCount == 1) {
            $verb = "was";
            $last = "roll"; 
        print "<p> There {$verb} {$rollCount} {$last}!</p>";
        $roll = false;


The expression is never found in a case so the loop goes forever. Change to

switch ($roll) {

There needs to be some form of exit condition in the loop. It can be based upon $rollcount, or you could add one more case,

case 6:
    echo "<div class=\"coin\">6</div>";

Set the others to match their case, and use case 0 to break

case 0:

Then change to rand(0, 6)