this is my first post. I am sorry for the totally amateur question but I want to learn PHP so I started doing some online courses-tutorials for PHP and there was an example without explanation and I can't find the answer on google.
In the code line 4 $flip = rand(0,1); that means that $flip is getting a random number 0 or 1 right? Then at line 6 there is if ($flip) { ... But they don't explain what "if ($flip)" means or equals to. For example $flip = 1 or $flip = 0. Thank you in advance.
$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>";