3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ public static $alphabet = 'ABCDEFGHIKLMNOPQRSTVXYZabcdefghiklmnopqrstvxyz'; public static function shorten($number) { $alphabet = self::$alphabet; $base = strlen($alphabet); $number = intval($number, 10); $shortened = ""; while ($number > 0) { $remainder = $number % $base; $shortened .= $alphabet[$remainder] $number = (int) ($number / $base); } return $shortened; } public static function unshorten($string) { $alphabet = self::$alphabet; $base = strlen($alphabet); $length = strlen($string); $returnVal = 0; for ($i=$length-1; $i >= 0; --$i) { $ind = strpos($alphabet, $string[$i]); if ($ind === false) { return false; } $returnVal += (int)($ind * pow($base, $i)); } return $returnVal; } } $shortened = Foo::shorten(12343336363636636); echo $shortened . "\n"; var_dump(Foo::unshorten($shortened));

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)
5.4.270.0100.05318.95
5.4.260.0070.05719.02
5.4.250.0070.07718.83
5.4.240.0030.07319.09
5.4.230.0100.05718.83
5.4.220.0100.07318.96
5.4.210.0170.07319.04
5.4.200.0000.05718.76
5.4.190.0230.05318.78
5.4.180.0200.06318.64
5.4.170.0170.06318.75
5.4.160.0200.06018.93
5.4.150.0200.06718.80
5.4.140.0200.05016.43
5.4.130.0130.06016.48
5.4.120.0070.06716.57
5.4.110.0100.06016.32
5.4.100.0100.06316.38
5.4.90.0200.05716.41
5.4.80.0100.06716.60
5.4.70.0030.07016.41
5.4.60.0100.07016.36
5.4.50.0170.04716.38
5.4.40.0270.06016.54
5.4.30.0170.06016.38
5.4.20.0100.06016.32
5.4.10.0000.06016.58
5.4.00.0070.06715.97
5.3.280.0100.06714.71
5.3.270.0200.06714.58
5.3.260.0130.06314.83
5.3.250.0100.05314.61
5.3.240.0100.07014.70
5.3.230.0130.06714.69
5.3.220.0100.06714.57
5.3.210.0100.07014.64
5.3.200.0230.05314.65
5.3.190.0130.05014.74
5.3.180.0070.05314.64
5.3.170.0130.05014.55
5.3.160.0100.07314.47
5.3.150.0170.05014.63
5.3.140.0170.05714.63
5.3.130.0030.07014.57
5.3.120.0130.08014.62
5.3.110.0070.06014.55
5.3.100.0130.05714.06
5.3.90.0170.06714.08
5.3.80.0170.04714.03
5.3.70.0130.06313.92
5.3.60.0070.06314.00
5.3.50.0030.07014.17
5.3.40.0030.08014.03
5.3.30.0000.06713.93
5.3.20.0100.05713.86
5.3.10.0100.06713.73
5.3.00.0100.05313.71
5.2.170.0030.06011.22
5.2.160.0070.06311.13
5.2.150.0070.04011.05
5.2.140.0070.04711.20
5.2.130.0170.04311.09
5.2.120.0100.05711.09
5.2.110.0100.04711.11
5.2.100.0070.04310.93
5.2.90.0100.05311.19
5.2.80.0000.06311.20
5.2.70.0100.05711.05
5.2.60.0070.04711.06
5.2.50.0070.04311.24
5.2.40.0030.04011.09
5.2.30.0070.04710.93
5.2.20.0070.05711.05
5.2.10.0100.03311.04
5.2.00.0000.06310.80
5.1.60.0070.04710.19
5.1.50.0070.04710.19
5.1.40.0030.0409.95
5.1.30.0070.04310.41
5.1.20.0070.06710.26
5.1.10.0070.04710.16
5.1.00.0130.04710.13
5.0.50.0100.0308.64
5.0.40.0070.0238.51
5.0.30.0200.0438.29
5.0.20.0000.0438.43
5.0.10.0070.0278.17
5.0.00.0030.0478.40
4.4.90.0070.0275.97
4.4.80.0070.0275.84
4.4.70.0030.0305.95
4.4.60.0000.0235.82
4.4.50.0030.0275.85
4.4.40.0130.0335.86
4.4.30.0030.0235.82
4.4.20.0070.0205.96
4.4.10.0070.0305.91
4.4.00.0030.0405.86
4.3.110.0070.0275.78
4.3.100.0000.0235.75
4.3.90.0030.0275.74
4.3.80.0070.0375.80
4.3.70.0070.0275.77
4.3.60.0030.0205.72
4.3.50.0030.0275.77
4.3.40.0300.0275.67
4.3.30.0030.0235.66
4.3.20.0000.0235.66
4.3.10.0000.0275.66
4.3.00.0100.0176.58

preferences:
141.1 ms | 1394 KiB | 7 Q