3v4l.org

run code in 300+ PHP versions simultaneously
<?php $code=' array( 0 => "a", "a" => $GlobalScopeVar, "b" => array("nested"=>array(1,2,3)), "c" => function() use (&$VAR) { return isset($VAR) ? "defined" : "undefined" ; }, "string_literal", 12345 ) '; $token = token_get_all("<?php ".$code); $newcode = ""; $i = 0; while (++$i < count($token)) { // enter into array; then start. if (is_array($token[$i])) $newcode .= $token[$i][1]; else $newcode .= $token[$i]; if ($token[$i] == "(") { $ending = ")"; break; } if ($token[$i] == "[") { $ending = "]"; break; } } // init variables $escape = 0; $wait_for_non_whitespace = 0; $parenthesis_count = 0; $entry = ""; // main loop while (++$i < count($token)) { // don't match commas in func($a, $b) if ($token[$i] == "(" || $token[$i] == "{") // ( -> normal parenthesis; { -> closures $parenthesis_count++; if ($token[$i] == ")" || $token[$i] == "}") $parenthesis_count--; // begin new string after T_DOUBLE_ARROW if (!$escape && $wait_for_non_whitespace && (!is_array($token[$i]) || $token[$i][0] != T_WHITESPACE)) { $escape = 1; $wait_for_non_whitespace = 0; $entry .= "'"; } // here is a T_DOUBLE_ARROW, there will be a string after this if (is_array($token[$i]) && $token[$i][0] == T_DOUBLE_ARROW && !$escape) { $wait_for_non_whitespace = 1; } // entry ended: comma reached if (!$parenthesis_count && $token[$i] == "," || ($parenthesis_count == -1 && $token[$i] == ")" && $ending == ")") || ($ending == "]" && $token[$i] == "]")) { // go back to the first non-whitespace $whitespaces = ""; if ($parenthesis_count == -1 || ($ending == "]" && $token[$i] == "]")) { $cut_at = strlen($entry); while ($cut_at && ord($entry[--$cut_at]) <= 0x20); // 0x20 == " " $whitespaces = substr($entry, $cut_at + 1, strlen($entry)); $entry = substr($entry, 0, $cut_at + 1); } // $escape == true means: there was somewhere a T_DOUBLE_ARROW if ($escape) { $escape = 0; $newcode .= $entry."'"; } else { $newcode .= "'".str_replace(array("'", "\\"), array("\\'", "\\\\"), $entry)."'"; } $newcode .= $whitespaces.($parenthesis_count?")":(($ending == "]" && $token[$i] == "]")?"]":",")); // reset $entry = ""; } else { // add actual token to $entry if (is_array($token[$i])) { $addChar = $token[$i][1]; } else { $addChar = $token[$i]; } if ($entry == "" && $token[$i][0] == T_WHITESPACE) { $newcode .= $addChar; } else { $entry .= $escape?str_replace(array("'", "\\"), array("\\'", "\\\\"), $addChar):$addChar; } } } //append remaining chars like whitespaces or ; $newcode .= $entry; print $newcode;

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.70.0090.00618.37
8.3.60.0200.00018.68
8.3.50.0100.00921.27
8.3.40.0070.00718.66
8.3.30.0110.00319.21
8.3.20.0070.00020.13
8.3.10.0030.00622.09
8.3.00.0050.00322.40
8.2.180.0060.00916.63
8.2.170.0120.00622.96
8.2.160.0080.00519.27
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0160.00326.16
8.2.120.0080.00419.36
8.2.110.0060.00320.43
8.2.100.0120.00017.85
8.2.90.0000.00918.28
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0000.00817.80
8.2.50.0080.00018.07
8.2.40.0050.00319.88
8.2.30.0080.00018.14
8.2.20.0040.00417.85
8.2.10.0040.00417.80
8.2.00.0050.00317.67
8.1.280.0120.00925.92
8.1.270.0090.00022.00
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00622.19
8.1.230.0080.00320.97
8.1.220.0040.00417.80
8.1.210.0060.00218.77
8.1.200.0070.00317.22
8.1.190.0040.00417.54
8.1.180.0090.00018.70
8.1.170.0030.00618.36
8.1.160.0030.00622.10
8.1.150.0090.00018.60
8.1.140.0040.00417.50
8.1.130.0000.00717.87
8.1.120.0030.00517.59
8.1.110.0040.00417.54
8.1.100.0050.00317.45
8.1.90.0000.00717.48
8.1.80.0040.00417.49
8.1.70.0070.00017.46
8.1.60.0040.00417.56
8.1.50.0040.00417.58
8.1.40.0040.00417.60
8.1.30.0000.00817.67
8.1.20.0000.00817.71
8.1.10.0040.00417.62
8.1.00.0000.00917.57
8.0.300.0030.00620.32
8.0.290.0000.00717.30
8.0.280.0000.00718.41
8.0.270.0030.00317.31
8.0.260.0080.00016.85
8.0.250.0000.00817.09
8.0.240.0000.00716.91
8.0.230.0000.00717.00
8.0.220.0040.00416.83
8.0.210.0030.00316.85
8.0.200.0080.00016.99
8.0.190.0000.00716.93
8.0.180.0030.00516.86
8.0.170.0000.00816.86
8.0.160.0000.00816.90
8.0.150.0040.00416.97
8.0.140.0040.00416.91
8.0.130.0070.00013.39
8.0.120.0060.00316.86
8.0.110.0000.00816.91
8.0.100.0000.00717.00
8.0.90.0080.00016.91
8.0.80.0100.00716.88
8.0.70.0030.00516.74
8.0.60.0060.00316.95
8.0.50.0050.00317.00
8.0.30.0130.00517.08
8.0.20.0090.01217.40
8.0.10.0070.00016.95
8.0.00.0090.01216.80
7.4.330.0050.00015.12
7.4.320.0030.00316.54
7.4.300.0050.00216.55
7.4.290.0030.00316.63
7.4.280.0070.00016.44
7.4.270.0000.00716.65
7.4.260.0030.00316.67
7.4.250.0000.00716.54
7.4.240.0040.00316.55
7.4.230.0030.00316.46
7.4.220.0100.00716.76
7.4.210.0060.00916.57
7.4.200.0070.00016.48
7.4.190.0000.00716.81
7.4.160.0110.01116.55
7.4.150.0150.00317.40
7.4.140.0100.00817.86
7.4.130.0070.01016.57
7.4.120.0100.00716.52
7.4.110.0030.01616.47
7.4.100.0090.00916.48
7.4.90.0100.00716.52
7.4.80.0130.00519.39
7.4.70.0050.01116.56
7.4.60.0080.00816.41
7.4.50.0030.00516.51
7.4.40.0040.01522.77
7.4.30.0030.01316.55
7.4.00.0110.00715.05
7.3.330.0050.00013.26
7.3.320.0030.00313.27
7.3.310.0000.00716.35
7.3.300.0030.00316.40
7.3.290.0030.01216.35
7.3.280.0130.00316.36
7.3.270.0070.01017.40
7.3.260.0120.01216.44
7.3.250.0060.01116.39
7.3.240.0120.00616.64
7.3.230.0030.01216.39
7.3.210.0090.00816.51
7.3.200.0180.00419.39
7.3.190.0100.01416.59
7.3.180.0070.01016.53
7.3.170.0100.00716.72
7.3.160.0060.01016.48
7.3.120.0110.00715.03
7.2.330.0090.00916.71
7.2.320.0090.00916.80
7.2.310.0000.01616.76
7.2.300.0080.00816.65
7.2.290.0060.00916.59
7.1.70.0000.01917.23
7.1.60.0080.00417.20
7.1.50.0110.01116.99
7.1.00.0000.03722.42
7.0.200.0070.00716.82
7.0.140.0070.07322.01
7.0.60.0270.07720.11
7.0.50.0100.07717.86
7.0.40.0170.08020.08
7.0.30.0400.07020.09
7.0.20.0170.09020.09
7.0.10.0170.05320.18
7.0.00.0030.05320.11
5.6.280.0070.07021.19
5.6.210.0070.03720.65
5.6.200.0130.04318.13
5.6.190.0030.04720.57
5.6.180.0270.04720.39
5.6.170.0170.04720.62
5.6.160.0130.08020.50
5.6.150.0100.06318.11
5.6.140.0100.08318.18
5.6.130.0070.08318.16
5.6.120.0130.05021.18
5.6.110.0070.05021.15
5.6.100.0030.09021.04
5.6.90.0100.08020.98
5.6.80.0030.07020.38
5.5.350.3630.03320.45
5.5.340.0030.05718.02
5.5.330.0100.05020.40
5.5.320.0270.04720.23
5.5.310.0370.07720.30
5.5.300.0030.08718.00
5.5.290.0100.04017.92
5.5.280.0030.04020.80
5.5.270.0070.05320.84
5.5.260.0070.03720.90
5.5.250.0170.08020.62
5.5.240.0000.07320.23
5.4.450.3370.03319.21
5.4.440.3670.04019.50
5.4.430.1430.06319.41
5.4.420.3800.04319.50
5.4.410.3530.04019.25
5.4.400.3770.04019.09
5.4.390.3370.04018.96
5.4.380.3800.03319.13
5.4.370.3400.03319.14
5.4.360.3630.03719.14
5.4.350.3900.03319.00
5.4.340.3730.02718.96
5.4.320.3970.03719.14
5.4.310.3730.04018.91
5.4.300.3500.03319.14
5.4.290.3770.04019.14
5.4.280.3900.04019.14
5.4.270.3600.03718.86
5.4.260.3900.04319.12
5.4.250.4070.03318.93
5.4.240.3570.03719.07
5.4.230.3800.03719.14
5.4.220.3670.03718.92
5.4.210.3670.03718.88
5.4.200.3800.03719.14
5.4.190.3670.03019.14
5.4.180.3470.04019.07
5.4.170.3770.03318.92
5.4.160.3770.03019.12
5.4.150.3900.04319.11
5.4.140.4530.03716.37
5.4.130.4630.03016.44
5.4.120.4000.04016.48
5.4.110.3570.03316.39
5.4.100.3330.03716.46
5.4.90.3630.03016.28
5.4.80.3700.03716.43
5.4.70.3700.03716.39
5.4.60.3530.03716.37
5.4.50.4100.04016.28
5.4.40.4170.04016.40
5.4.30.3730.03316.39
5.4.20.4170.04016.51
5.4.10.3630.03316.38
5.4.00.3900.04015.85
5.3.290.3870.03714.82
5.3.280.3670.03014.68
5.3.270.3870.04014.50
5.3.260.3770.04014.61
5.3.250.4000.03314.61
5.3.240.4500.03714.50
5.3.230.4330.02714.48
5.3.220.3870.03714.56
5.3.210.3770.03714.58
5.3.200.3670.02714.53
5.3.190.5100.03314.56
5.3.180.5070.02714.64
5.3.170.4000.04314.57
5.3.160.4070.04314.42
5.3.150.3870.03714.45
5.3.140.4170.04314.54
5.3.130.3600.03714.40
5.3.120.4170.04714.59
5.3.110.3900.03314.57
5.3.100.3330.03314.05
5.3.90.3630.04014.11
5.3.80.3600.03313.91
5.3.70.3600.03313.92
5.3.60.4330.03714.03
5.3.50.3770.02313.84
5.3.40.3670.03313.80
5.3.30.3630.03313.96
5.3.20.3570.03313.70
5.3.10.0000.03713.65
5.3.00.2400.04313.59
5.2.170.3000.03011.07
5.2.160.3000.02711.14
5.2.150.2700.02711.14
5.2.140.3100.02711.16
5.2.130.1270.02711.07
5.2.120.0030.02711.11
5.2.110.0000.03011.10
5.2.100.2970.02711.11
5.2.90.3000.02711.11
5.2.80.2930.03011.15
5.2.70.3470.03311.10
5.2.60.3200.02711.00
5.2.50.3300.03011.17
5.2.40.2770.03010.95
5.2.30.2770.03010.97
5.2.20.2370.03311.01
5.2.10.2400.03010.88
5.2.00.2400.02710.77
5.1.60.2470.02310.01
5.1.50.3000.0239.91
5.1.40.2570.02710.04
5.1.30.2400.03010.39
5.1.20.2530.03010.32
5.1.10.2370.02710.14
5.1.00.2400.02710.11
5.0.50.1230.0238.68
5.0.40.1470.0238.54
5.0.30.0000.0408.22
5.0.20.0000.0208.31
5.0.10.0000.0508.22
5.0.00.0000.0578.40
4.4.90.1400.0176.29
4.4.80.1300.0236.29
4.4.70.1430.0206.29
4.4.60.1300.0176.29
4.4.50.1630.0136.29
4.4.40.1200.0276.29
4.4.30.1500.0206.29
4.4.20.1230.0176.29
4.4.10.1470.0176.29
4.4.00.1400.0306.29
4.3.110.0030.0206.29
4.3.100.0030.0136.29
4.3.90.0030.0376.29
4.3.80.0070.0276.29
4.3.70.0000.0206.29
4.3.60.0030.0276.29
4.3.50.0870.0136.29
4.3.40.1700.0276.29
4.3.30.0900.0236.29
4.3.20.0830.0136.29
4.3.10.0930.0206.29
4.3.00.0730.0176.29

preferences:
48.54 ms | 401 KiB | 5 Q