This forum is now read-only. Please use our new forums at

While Loops in PHP Forum

View Course » View Exercise

85 points
Submitted by
almost 4 years ago

[resolved] 5/7 I am confused about the result, it only flips one and the result is tail

As the condition said that the coin will flip until the result is H or head then how come the result come as T or tail and stop flipping the coin and says "There was one flip". Any body found this? Can someone clear me?Thanks.

0 votes


The condition says: "while the result is heads" not "until the result is heads". So it will keep flipping as long as rand(0,1) produces a 1 (a head). As soon as you get a 0 (a tail) it echos that and then it stops.

3698 points
Submitted by
almost 4 years ago


521e65b39a7b1858905848aff1689ebc?s=140&d=retro junayed almost 4 years ago

ok, thank you for the answer. Now it is clear.

55df2afa95e3787b9200005e_359368177 Judy almost 4 years ago

You're welcome, I'm glad it helped.

0 votes


i still don't understand this. It is a bit confusing how the developers are teaching this. Why not just say completely stop at tails, when the FIRST tails appears, regardless of heads showing or not?

272 points
Submitted by
over 3 years ago