- rand: documentation ( source)
<?php
$win = 0;
$lose = 0;
for ($i=0;$i<=10000;$i++)
{
$throw1 = rand(1,2); // 1 = head, 2 = tail
$throw2 = rand(1,2);
if($throw1 == 1 or $throw2 == 1)
{
if($throw1==1 && $throw2 ==1)
{
$win++;
}
else
{
$lose++;
}
}
}
echo $win." ";
echo $lose;
echo " Proba=".($win/($win+$lose));
?>