I need some help with the exercise 7/7


#1

Hi
This is my first question on the forum, i'm very confused.
In this exercise, i will do a cycle for my own, and exercise advice tells me to do a variation of Exercise 5, which is this:

    <?php
        //escribí tu propio ciclo do-while a continuación
        $conteoDeLanzamientos = 0;
	do {
		$lanzamiento = rand(0,1);
		$conteoDeLanzamientos ++;
		if ($lanzamiento){
			echo "<div class=\"coin\">H</div>";
		}
		else {
			echo "<div class=\"coin\">T</div>";
		}
	} while ($lanzamiento);
	$verbo = "fueron";
	$final = "lanzamientos";
	if ($conteoDeLanzamientos == 1) {
		$verbo = "fueron";
		$final = "lanzamientos";
	}
	echo "<p> {$verbo} {$conteoDeLanzamientos} {$final}!</p>";
        
    ?>

but throwing a six-sided die until a 6.
and then he tells me to use rand (1.6) and the variable $throw and after that continue the cycle at the condition! = 6 ??????

I don't know what to do,
i want to understand this exercise
Bye:slight_smile:


#2

<!DOCTYPE html>
<html>
<head>
<title>Your own do-while</title>
<link rel='stylesheet' href='style.css'>
</head>
<body>
<p>We will keep rollling a dice until the result is 6!</p>
<?php
$rollCount = 0;
do {
$roll = rand(1,6);
$rollCount ++;
if ($roll == 6){
echo"<p>We got 6!!!</p>";
} else {
echo"<p>We got {$roll} :(</p>";
}
}
while ($roll != 6);
$verb = "were";
$last = "rolls";
if ($rollCount == 1) {
$verb = "was";
$last = "roll";
}
echo "<p>There {$verb} {$rollCount} {$last}!</p>";
?>
</body>
</html>