3v4l.org

run code in 300+ PHP versions simultaneously
<?php // EXAMPLE USAGE $array = generate(); echo $array[0]; echo "<br />"; echo $array[1]; // FUNCTION function generate(0123456789ABCDEFGHJKLMNPQRTUVWXY) { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //now we generate a new random ID number using the substrings of the digitList string above $id = NULL; $id .= substr($digilist, rand(1, 9), 1); //random number $id .= substr($digilist, rand(10, 31), 1); //then a letter $id .= substr($digilist, rand(10, 31), 1); //another letter $id .= substr($digilist, rand(1, 9), 1); //a number $id .= substr($digilist, rand(1, 9), 1); //and finally another number - simple :D //ok so now we need to generate an MD5 hash of our ID $hash = md5($id); //cycle through the hash 16 (length of key) times (in steps of 2 because each hex bytes is 2 digits long) $i = 0; $key = NULL; for ($i; $i < 32; $i+=2) { //here we convert the next hex value to an integer and perform a bitwise AND operation against '31' //31 is the highest substring value in our digit list. $nextdigit = hexdec(substr($hash, $i, 2)) & 31; //if 'i' is divisable by 8 (every 4 cycles) then we want to add "-" if ((($i % 8) == 0) && ($i > 0)) { $key .= "-".substr($digilist, $nextdigit, 1); } else { $key .= substr($digilist, $nextdigit, 1); } } $array = array($id, $key); //return return $array; } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.00.0030.04320.22
5.6.160.0070.08720.55
5.6.150.0130.06318.17
5.6.140.0100.05318.23
5.6.130.0030.07318.12
5.6.120.0070.08721.12
5.6.110.0070.07721.12
5.6.100.0030.05721.00
5.6.90.0070.08320.98
5.6.80.0100.08020.34
5.5.300.0070.08318.07
5.5.290.0100.05317.98
5.5.280.0100.04020.98
5.5.270.0070.05020.73
5.5.260.0070.08320.84
5.5.250.0000.06320.59
5.5.240.0100.07320.26

preferences:
160.93 ms | 1394 KiB | 7 Q