Wednesday, September 11, 2013

if multiple random numbers are all equal return true

if multiple random numbers are all equal return true

Im working on some random generator, and it's something like roll a dices,
if all dices are returning same numbers than you won a game if not than
you try again.
To get six dices i used mt_rand function and for every dice separately, so
i have this:
$first = mt_rand(1,6);
$second = mt_rand(1,6);
$third = mt_rand(1,6);
$fourth = mt_rand(1,6);
$fifth = mt_rand(1,6);
$sixth = mt_rand(1,6);
But i don't know how to return if operand for multiple random generated
numbers.
If i would use like 2 dices i would just use
if ( $first === $second )
that would return true if first and second dices, both have returned number 2
But how do i use it if i want to echo true if all 6 dices to return number
2 ?

No comments:

Post a Comment