3v4l.org

run code in 300+ PHP versions simultaneously
<?php printf("PHP_VERSION=%s\n",PHP_VERSION); $min = -(mt_getrandmax()>>1); $max = mt_getrandmax(); $count = isset($argv[1])?(int)$argv[1]:16; printf("min=%d, max=%d, count=%d\n",$min,$max,$count); $repeat_counts = array(); for ($i=0;$i<$count;$i++) { $random = mt_rand($min,$max); if (!isset($repeat_counts[$random])) { $repeat_counts[$random] = 0; } $repeat_counts[$random]++; //printf("%12d%s\n", abs($random),($random<0)?"-":""); } $max_repeat_count = max($repeat_counts); $same_value_max = array(); if ($max_repeat_count > 1) { foreach ($repeat_counts as $value => $repeat_count) { if ($repeat_count >= $max_repeat_count) { $same_value_max[] = $value; } } printf("The following number/s was/were repeated %d times (%s%%): %s\n" ,$max_repeat_count ,number_format(($max_repeat_count/$count)*100.0,1) ,implode(", ",$same_value_max) ); }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
PHP_VERSION=7.4.0 min=-1073741823, max=2147483647, count=16

preferences:
52.25 ms | 1586 KiB | 4 Q