3v4l.org

run code in 500+ 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
PHP_VERSION=4.3.0 min=-1073741823, max=2147483647, count=16
Output for 4.4.0 - 4.4.9
PHP_VERSION=4.4.0 min=-1073741823, max=2147483647, count=16
Output for 5.0.0 - 5.0.5
PHP_VERSION=5.0.0 min=-1073741823, max=2147483647, count=16
Output for 5.1.0 - 5.1.6
PHP_VERSION=5.1.0 min=-1073741823, max=2147483647, count=16
Output for 5.2.0 - 5.2.17
PHP_VERSION=5.2.0 min=-1073741823, max=2147483647, count=16
Output for 5.3.0 - 5.3.29
PHP_VERSION=5.3.0 min=-1073741823, max=2147483647, count=16
Output for 5.4.0 - 5.4.45
PHP_VERSION=5.4.0 min=-1073741823, max=2147483647, count=16
Output for 5.5.0 - 5.5.38
PHP_VERSION=5.5.0 min=-1073741823, max=2147483647, count=16
Output for 5.6.0 - 5.6.40
PHP_VERSION=5.6.0 min=-1073741823, max=2147483647, count=16
Output for 7.0.0 - 7.0.33
PHP_VERSION=7.0.0 min=-1073741823, max=2147483647, count=16
Output for 7.1.0 - 7.1.33
PHP_VERSION=7.1.0 min=-1073741823, max=2147483647, count=16
Output for 7.2.0 - 7.2.34
PHP_VERSION=7.2.0 min=-1073741823, max=2147483647, count=16
Output for 7.3.0 - 7.3.33
PHP_VERSION=7.3.0 min=-1073741823, max=2147483647, count=16
Output for 7.4.0
PHP_VERSION=7.4.0 min=-1073741823, max=2147483647, count=16

preferences:
27.24 ms | 1136 KiB | 7 Q