dongpian6319 2013-04-26 08:53
浏览 46

模拟头部或尾部

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?

  • 写回答

2条回答 默认 最新

  • drcmg28484 2013-04-26 08:57
    关注

    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.

    评论

报告相同问题?