#1

``````\$rollCount = 0;
do {
\$roll = rand(1, 6);
\$rollCount++;
if (\$roll) {
echo "<div class=\"coin\">H</div>";
}
else {
echo "<div class=\"coin\">T</div>";
}
}
while (\$roll) ;
\$verb = "were";
\$last = "flips";
if (\$rollCount == 1) {
\$verb = "was";
\$last = "flip";
}
echo "<p>There {\$verb} {\$rollCount} {\$last}!</p>";
.``````

`indent preformatted text by 4 spaces`

#2

This will always be true since your range begins with 1. Shift the range from 1, 6 to 0, 5 and see what happens.

Then write,

``````\$roll = rand(0, 5);
if (\$roll % 2) {``````

letting H be odd. Otherwise, write to the solution. This is a binary problem, not a dice problem.

``\$roll = rand(0, 1);``

Only two outcomes, as meets our needs.

``if (\$roll) {``

will still focus on the odd, and also on the truthy.

Then again, since we don't know what lesson this is we're only speculating. Please post a link to the exercise and the error messages appearing in the editor (SCT) and the console (parser).

Consider also how `rand()` works. We can give it a min and max for practically any range, or just let it be itself, rendering in a range of (0, 2E15-1). That's 32,768 random possibilites.

We further narrow this down with modulo.

``echo rand() % 6 + 1``

will simulate a die roll.

``````<html>
<?php
function la_matrice() {
return rand() % 6 + 1;
}
?>
<p>
<?php
// Get the length of your own name
// and print it to the screen!
\$length = strlen("weegillis");
print \$length;
?>
<?php
for (\$i = 0; \$i < 6; \$i++) {
echo '<br>';
echo la_matrice();
}
?>
</p>
</html>``````