3v4l.org

run code in 300+ PHP versions simultaneously
<?php $loopCount = 1e6; $min = 0; $max = mt_getrandmax()*2; $res = [ 'odd' => 0, 'even'=> 0, ]; while ($loopCount--) { $v = rand($min, $max); $v%2 ? $res['odd']++ : $res['even']++; } var_dump($res);
Output for 8.2.6
array(2) { ["odd"]=> int(499686) ["even"]=> int(500314) }
Output for 7.4.33
array(2) { ["odd"]=> int(500905) ["even"]=> int(499095) }
Output for 5.6.31 - 5.6.40, 7.0.33
array(2) { ["odd"]=> int(1000000) ["even"]=> int(0) }

preferences:
29.78 ms | 408 KiB | 5 Q