Trying to understand one part of the code in 5/7 section in "While Loops in PHP"


Hi to you all.
Can someone please explain me, in 5/7 section, this part of code, particularly "if ($flipCount == 1)":

if ($flipCount == 1) {
		$verb = "was";
		$last = "flip";
	echo "<p>There {$verb} {$flipCount} {$last}!</p>";

Why does it matter if $flipCount == 1? I mean, how it will print on screen how many times there were flips if that variable $flipCount is equal to 1?
Please understand that I am beginner and sorry for bad english.Thank you all in advance.


well, if there are two more or flips you want to print:

There were 2 flips!

(or 3, 4 or 5 and so on)
which you do here:

echo "<p>There {$verb} {$flipCount} {$last}!</p>";

the variable are here:

    $verb = "were";
    $last = "flips";

however, if there is only one flip, you want the $verb to be was (not were), and $last to be flip (one flip, multiply flips)

So, the if statement just ensures the sentence is correct in case of a single flip


Oh, now I get it. Thank you very much. :slightly_smiling: