3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roll ($probability, $precision = 5) { if ($probability == 0) { return null; } return mt_rand(1, pow(10, $precision) / $probability) / pow(10, $precision); } $rolls = array(); for ($i = 0; $i < 500; $i++) { $rolls[roll(0.25)]++; } var_dump($rolls); if (roll(0.25) === 0) { print "Winner"; }

preferences:
32.69 ms | 402 KiB | 5 Q