3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Duplicates an array, even if the array contains * references. * * @param $arr array The array to duplicate. * @return array The duplicate of the array. */ function array_dup($arr) { $ret = []; foreach ($arr as $key => $value) $ret[$key] = $value; return $ret; } /** * Create an array of references to the elements of an array. * * @param $arr array The array to create references to. * @return array */ function refArray(&$arr) { $refs = []; foreach ($arr as $key => $value) $refs[$key] = &$arr[$key]; return $refs; } /** * Invokes a callback while capturing the output buffer * changes produced by it, and returns those changes as * a string. * * @param $callback callback The function to call. * @return string */ function captureOutputBuffer($callback) { ob_start(); $callback(); $dat = ob_get_contents(); if ($dat === false || ob_end_clean() !== true) throw new LogicException('ERROR: Something is wrong! Failed to retrieve the buffer\'s body!'); return $dat; } /** * Clean a partial page path of all invalid characters, * and ready it for lookup in the database. * * @param $path string The path to clean. * @return string A clean version of the path. */ function cleanPagePath($path) { $path = strtolower(rtrim($path, '/')); $tmp = ''; $pathLength = strlen($path); for ($i = 0; $i < $pathLength; $i++) { switch ($path[$i]) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '_': case '-': case '/': $tmp .= $path[$i]; continue; // Backslashes are looked up as forward slashes. case '\\': $tmp .= '/'; continue; // Spaces are replaced with underscores. case ' ': $tmp .= '_'; continue; default: continue; } } return $tmp; }

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)
8.3.60.0120.00316.88
8.3.50.0090.00922.00
8.3.40.0070.01518.70
8.3.30.0040.01419.14
8.3.20.0040.00420.30
8.3.10.0040.00421.91
8.3.00.0070.00320.74
8.2.180.0100.01018.54
8.2.170.0130.00322.96
8.2.160.0140.00020.44
8.2.150.0030.00524.18
8.2.140.0030.00624.66
8.2.130.0080.00026.16
8.2.120.0030.00619.41
8.2.110.0040.00420.52
8.2.100.0060.00617.63
8.2.90.0030.00518.91
8.2.80.0000.00817.97
8.2.70.0000.00917.50
8.2.60.0000.00917.80
8.2.50.0070.00318.07
8.2.40.0030.00518.03
8.2.30.0040.00417.99
8.2.20.0040.00417.59
8.2.10.0030.00517.87
8.2.00.0020.00517.53
8.1.280.0060.01225.92
8.1.270.0040.00420.71
8.1.260.0050.00226.35
8.1.250.0000.00728.09
8.1.240.0060.00319.01
8.1.230.0040.00817.42
8.1.220.0030.00617.74
8.1.210.0060.00318.77
8.1.200.0080.00417.22
8.1.190.0000.00917.09
8.1.180.0040.00418.10
8.1.170.0040.00420.23
8.1.160.0000.00722.05
8.1.150.0070.00018.88
8.1.140.0050.00217.44
8.1.130.0000.00717.81
8.1.120.0030.00717.41
8.1.110.0000.00717.36
8.1.100.0030.00317.34
8.1.90.0040.00417.35
8.1.80.0000.00817.38
8.1.70.0000.00817.32
8.1.60.0030.00517.46
8.1.50.0080.00017.50
8.1.40.0080.00017.44
8.1.30.0000.00817.52
8.1.20.0040.00417.55
8.1.10.0090.00017.39
8.1.00.0070.00317.35
8.0.300.0080.00018.77
8.0.290.0040.00416.75
8.0.280.0000.00718.43
8.0.270.0000.00717.11
8.0.260.0060.00017.17
8.0.250.0000.00716.96
8.0.240.0030.00316.91
8.0.230.0110.00016.92
8.0.220.0030.00316.75
8.0.210.0030.00516.91
8.0.200.0030.00316.96
8.0.190.0040.00416.92
8.0.180.0060.00316.76
8.0.170.0000.00816.92
8.0.160.0040.00416.96
8.0.150.0070.00016.73
8.0.140.0040.00416.86
8.0.130.0050.00013.34
8.0.120.0050.00316.83
8.0.110.0000.00716.93
8.0.100.0000.00716.95
8.0.90.0040.00416.88
8.0.80.0100.01116.88
8.0.70.0000.00716.78
8.0.60.0000.00716.90
8.0.50.0050.00316.68
8.0.30.0090.00916.97
8.0.20.0080.01117.40
8.0.10.0000.00717.02
8.0.00.0080.01016.58
7.4.330.0050.00015.03
7.4.320.0070.00016.52
7.4.300.0030.00316.58
7.4.290.0000.00916.43
7.4.280.0090.00316.28
7.4.270.0030.00316.45
7.4.260.0000.00716.46
7.4.250.0050.00216.48
7.4.240.0020.00616.39
7.4.230.0000.00716.63
7.4.220.0070.01016.42
7.4.210.0090.00616.55
7.4.200.0000.00716.64
7.4.160.0030.01216.38
7.4.150.0090.00917.40
7.4.140.0110.02317.86
7.4.130.0110.00516.34
7.4.120.0050.01316.47
7.4.110.0120.00916.38
7.4.100.0120.00916.40
7.4.90.0100.01016.36
7.4.80.0120.00619.39
7.4.70.0050.01116.50
7.4.60.0130.00316.48
7.4.50.0080.00016.31
7.4.40.0040.01216.43
7.4.30.0110.01116.55
7.4.00.0070.00715.05
7.3.330.0030.00313.37
7.3.320.0150.00013.25
7.3.310.0070.00016.25
7.3.300.0000.00716.34
7.3.290.0000.00716.17
7.3.280.0110.00816.31
7.3.270.0120.00917.40
7.3.260.0080.01116.31
7.3.250.0110.00716.33
7.3.240.0130.00716.46
7.3.230.0130.01016.47
7.3.210.0140.00316.29
7.3.200.0110.01119.39
7.3.190.0060.01016.41
7.3.180.0090.00916.53
7.3.170.0080.01316.27
7.3.160.0080.00816.44
7.3.10.0020.01116.58
7.3.00.0120.00716.38
7.2.330.0150.00416.38
7.2.320.0100.00716.58
7.2.310.0090.00916.52
7.2.300.0110.00616.42
7.2.290.0030.01716.39
7.2.130.0050.00816.40
7.2.120.0120.00516.68
7.2.110.0090.00916.74
7.2.100.0090.00516.65
7.2.90.0070.00616.72
7.2.80.0090.00516.70
7.2.70.0090.00316.71
7.2.60.0050.00916.77
7.2.50.0040.00716.46
7.2.40.0060.00816.71
7.2.30.0060.01016.54
7.2.20.0070.00716.59
7.2.10.0070.00916.59
7.2.00.0080.00817.44
7.1.250.0120.00615.56
7.1.200.0030.00815.46
7.1.100.0030.01017.81
7.1.70.0000.00817.07
7.1.60.0100.01419.46
7.1.50.0230.01334.69
7.1.00.0030.07722.46
7.0.200.0050.00514.78
7.0.140.0000.07321.95
7.0.70.4470.03719.96
7.0.60.0030.04319.98
7.0.50.0000.07317.94
7.0.40.0070.04320.09
7.0.30.0300.05720.25
7.0.20.0300.07320.06
7.0.10.0230.07320.10
7.0.00.0030.04320.23
5.6.280.0070.07021.06
5.6.210.0000.06720.63
5.6.200.0070.05318.22
5.6.190.0030.08320.60
5.6.180.0130.04320.56
5.6.170.0300.07720.40
5.6.160.0070.07720.54
5.6.150.0100.03318.19
5.6.140.0100.07318.30
5.6.130.0100.08018.21
5.6.120.0130.07720.91
5.6.110.0030.09021.16
5.6.100.0030.04021.16
5.6.90.0000.07321.06
5.6.80.0070.08020.43
5.6.70.0270.07020.53
5.5.350.0100.07720.37
5.5.340.0070.08018.01
5.5.330.0100.06720.21
5.5.320.0030.07720.47
5.5.310.0270.07320.56
5.5.300.0070.08718.08
5.5.290.0130.04318.05
5.5.280.0030.04320.92
5.5.270.0170.07720.81
5.5.260.0070.04020.81
5.5.250.0030.06720.57
5.5.240.0270.03720.06
5.4.450.0670.06019.48
5.4.440.0970.07019.17
5.4.430.0070.06019.61
5.4.420.0730.05719.45
5.4.410.0370.05019.45
5.4.400.0170.07318.85
5.4.390.0100.06718.77
5.4.380.0200.06718.63
5.4.370.0130.05318.58
5.4.360.0130.05318.51
5.4.350.0170.05318.79
5.4.340.0170.05018.50
5.4.320.0170.05318.77
5.4.310.0070.06018.77
5.4.300.0100.05718.84
5.4.290.0230.04718.74
5.4.280.0200.04718.77
5.4.270.0170.05018.77
5.4.260.0170.05018.61
5.4.250.0270.04318.71
5.4.240.0070.06018.51
5.4.230.0170.05018.64
5.4.220.0230.05018.57
5.4.210.0100.06018.56
5.4.200.0200.05716.58
5.4.190.0270.05018.50
5.4.180.0170.05318.79
5.4.170.0200.05718.73
5.4.160.0170.06018.55
5.4.150.0330.03718.68
5.4.140.0100.06016.24
5.4.130.0170.06316.30
5.4.120.0170.05716.48
5.4.110.0230.04316.24
5.4.100.0170.05016.29
5.4.90.0100.05716.29
5.4.80.0200.05016.34
5.4.70.0130.05016.24
5.4.60.0070.06016.32
5.4.50.0230.04316.26
5.4.40.0130.06016.31
5.4.30.0100.05316.26
5.4.20.0230.04016.21
5.4.10.0130.05016.33
5.4.00.0170.05315.85
5.3.290.0130.06714.88
5.3.280.0200.04714.71
5.3.270.0100.05714.65
5.3.260.0170.05314.79
5.3.250.0170.05014.81
5.3.240.0130.05014.66
5.3.230.0200.04714.61
5.3.220.0200.04314.62
5.3.210.0170.05714.79
5.3.200.0170.04714.60
5.3.190.0200.04714.61
5.3.180.0100.05714.73
5.3.170.0170.05014.56
5.3.160.0200.05314.69
5.3.150.0130.05314.60
5.3.140.0130.06014.59
5.3.130.0170.05014.77
5.3.120.0130.05314.58
5.3.110.0230.04714.59
5.3.100.0070.05714.07
5.3.90.0130.05014.07
5.3.80.0170.04714.21
5.3.70.0170.04714.14
5.3.60.0200.07014.02
5.3.50.0230.04013.98
5.3.40.0130.05014.02
5.3.30.0070.05713.85
5.3.20.0230.04013.79
5.3.10.0200.05013.78
5.3.00.0170.05713.63
5.2.170.0100.04311.17
5.2.160.0130.05311.17
5.2.150.0100.04311.37
5.2.140.0200.03311.19
5.2.130.0170.03311.32
5.2.120.0070.04711.20
5.2.110.0170.03711.16
5.2.100.0100.04011.20
5.2.90.0100.04011.21
5.2.80.0130.04011.15
5.2.70.0100.04311.19
5.2.60.0030.04711.09
5.2.50.0130.03711.05
5.2.40.0130.03711.09
5.2.30.0070.04710.96
5.2.20.0200.03011.18
5.2.10.0130.03711.07
5.2.00.0070.04010.77
5.1.60.0070.04010.02
5.1.50.0170.0279.99
5.1.40.0100.03310.18
5.1.30.0170.03310.39
5.1.20.0070.04010.47
5.1.10.0100.03710.13
5.1.00.0130.03310.25
5.0.50.0100.0238.59
5.0.40.0070.0278.54
5.0.30.0030.0478.23
5.0.20.0100.0238.39
5.0.10.0030.0308.21
5.0.00.0070.0408.16
4.4.90.0030.0235.92
4.4.80.0030.0235.91
4.4.70.0000.0275.88
4.4.60.0030.0205.88
4.4.50.0100.0175.94
4.4.40.0070.0335.89
4.4.30.0030.0235.91
4.4.20.0000.0275.96
4.4.10.0000.0276.00
4.4.00.0000.0376.00
4.3.110.0030.0235.82
4.3.100.0000.0275.79
4.3.90.0000.0235.82
4.3.80.0030.0375.81
4.3.70.0030.0205.82
4.3.60.0000.0305.79
4.3.50.0030.0235.82
4.3.40.0100.0275.84
4.3.30.0070.0204.59
4.3.20.0030.0204.63
4.3.10.0000.0234.48
4.3.00.0130.0277.30

preferences:
48 ms | 401 KiB | 5 Q