What's the best way to simulate the concept of flipping a coin in PHP?
I need to random between true and false.
Is mt_rand(0, 1) a good solution?
What's the best way to simulate the concept of flipping a coin in PHP?
I need to random between true and false.
Is mt_rand(0, 1) a good solution?
Short answer: Yes.
Long answer: Make sure you seed well you random number generator, so you're sure that your result lists are various. Ok, this wasn't a so long answer, after all, but still yes, rolling a random between 0 and 1 looks like the fastest way to have a random true/false value.