Been requiring a lot of random numbers lately. Some simple routines I find useful for games of chance:
// virtual coin toss
$coinflip = mt_rand(1,2);
// actual virtual coin toss
if ( mt_rand(1,2) % 2 == 0 )
{
$flip = 'heads';
}
else
{
$flip = 'tails';
}
// roll the bones
$roll = mt_rand(1,6);