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 .= "'".addcslashes($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.60.0150.00318.30
8.3.50.0070.00922.03
8.3.40.0120.00318.73
8.3.30.0000.01518.71
8.3.20.0040.00418.73
8.3.10.0040.00421.21
8.3.00.0040.00423.56
8.2.180.0150.00316.36
8.2.170.0110.00422.96
8.2.160.0100.00320.52
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0070.00326.16
8.2.120.0060.00319.30
8.2.110.0070.00322.24
8.2.100.0040.00717.91
8.2.90.0040.00419.38
8.2.80.0000.00818.86
8.2.70.0000.00817.63
8.2.60.0030.00618.05
8.2.50.0030.00618.07
8.2.40.0050.00318.16
8.2.30.0000.00818.23
8.2.20.0000.00717.70
8.2.10.0040.00417.81
8.2.00.0040.00417.85
8.1.280.0090.00625.92
8.1.270.0040.00423.68
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0050.00523.91
8.1.230.0040.00719.11
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0000.00917.23
8.1.180.0080.00018.10
8.1.170.0040.00418.66
8.1.160.0060.00318.92
8.1.150.0040.00418.79
8.1.140.0000.00717.42
8.1.130.0000.00719.23
8.1.120.0050.00217.51
8.1.110.0040.00417.50
8.1.100.0040.00417.50
8.1.90.0030.00617.36
8.1.80.0040.00417.50
8.1.70.0040.00417.49
8.1.60.0050.00317.54
8.1.50.0090.00017.55
8.1.40.0000.00917.48
8.1.30.0000.00817.72
8.1.20.0050.00317.62
8.1.10.0030.00517.52
8.1.00.0040.00417.39
8.0.300.0000.00818.77
8.0.290.0070.00016.75
8.0.280.0030.00318.47
8.0.270.0000.00817.95
8.0.260.0030.00318.39
8.0.250.0030.00516.93
8.0.240.0090.00016.93
8.0.230.0080.00016.96
8.0.220.0060.00316.92
8.0.210.0050.00316.97
8.0.200.0000.00816.95
8.0.190.0040.00416.89
8.0.180.0050.00216.94
8.0.170.0040.00416.96
8.0.160.0040.00416.95
8.0.150.0040.00416.91
8.0.140.0000.00816.92
8.0.130.0000.00713.42
8.0.120.0030.00616.90
8.0.110.0030.00517.03
8.0.100.0030.00516.80
8.0.90.0050.00316.82
8.0.80.0000.01616.86
8.0.70.0030.00516.80
8.0.60.0040.00416.92
8.0.50.0070.00016.90
8.0.30.0100.00817.11
8.0.20.0120.00717.40
8.0.10.0040.00416.96
8.0.00.0070.01116.65
7.4.330.0050.00014.67
7.4.320.0000.00716.47
7.4.300.0000.00716.57
7.4.290.0000.00716.63
7.4.280.0000.00716.52
7.4.270.0040.00416.51
7.4.260.0000.00513.34
7.4.250.0000.00716.51
7.4.240.0000.00716.55
7.4.230.0030.00316.45
7.4.220.0040.01716.51
7.4.210.0070.01116.63
7.4.200.0000.00716.54
7.4.190.0040.00416.50
7.4.160.0070.01016.23
7.4.150.0110.00817.40
7.4.140.0140.00517.86
7.4.130.0060.01316.50
7.4.120.0080.00816.56
7.4.110.0100.00716.49
7.4.100.0070.01016.58
7.4.90.0060.01216.53
7.4.80.0060.01619.37
7.4.70.0070.01016.42
7.4.60.0120.00616.54
7.4.50.0030.00516.39
7.4.40.0070.00722.52
7.4.30.0070.01016.68
7.4.00.0070.01014.98
7.3.330.0030.00313.29
7.3.320.0030.00313.27
7.3.310.0030.00316.53
7.3.300.0030.00316.22
7.3.290.0030.01116.34
7.3.280.0060.01016.45
7.3.270.0130.00417.40
7.3.260.0080.01418.24
7.3.250.0090.01416.63
7.3.240.0090.00916.48
7.3.230.0080.00816.61
7.3.210.0120.00616.41
7.3.200.0030.01519.39
7.3.190.0100.00716.70
7.3.180.0030.01316.35
7.3.170.0080.00816.52
7.3.160.0080.00816.54
7.3.120.0040.01214.73
7.2.330.0000.01716.88
7.2.320.0190.00416.60
7.2.310.0130.01016.51
7.2.300.0070.01016.63
7.2.290.0060.00916.85
7.2.60.0080.00816.79
7.2.00.0030.01019.51
7.1.200.0060.00615.82
7.1.100.0000.01018.47
7.1.70.0130.00017.29
7.1.60.0050.01017.16
7.1.50.0080.02016.66
7.1.40.0170.00716.65
7.1.30.0100.01016.54
7.1.20.0090.00916.73
7.1.10.0100.01516.43
7.1.00.0340.00716.43
7.0.200.0050.00816.69
7.0.190.0050.01016.79
7.0.180.0080.00816.43
7.0.170.0000.01216.43
7.0.160.0070.00716.54
7.0.150.0070.01016.43
7.0.140.0390.01116.43
7.0.130.0700.01016.43
7.0.120.0680.00916.43
7.0.110.1000.01016.43
7.0.100.0430.00716.43
7.0.90.0520.00716.43
7.0.80.0410.01016.43
7.0.70.0540.00716.43
7.0.60.0600.00316.43
7.0.50.0570.01016.43
7.0.40.0050.00816.43
7.0.30.0120.00816.43
7.0.20.0070.01016.43
7.0.10.0090.00416.43
7.0.00.0040.00816.43
5.6.300.0000.05620.93
5.6.290.0000.05320.71
5.6.280.0170.08420.94
5.6.270.0030.07120.82
5.6.260.0130.07920.90
5.6.250.0070.05820.93
5.6.240.0140.05921.09
5.6.230.0070.05721.06
5.6.220.0140.08621.06
5.6.210.0100.08121.09
5.6.200.0190.06820.86
5.6.190.0230.04420.89
5.6.180.0100.06420.89
5.6.170.0100.07220.86
5.6.160.0070.06121.07
5.6.150.0070.04920.86
5.6.140.0090.04720.98
5.6.130.0040.04921.07
5.6.120.0000.09220.77
5.6.110.0140.06521.07
5.6.100.0070.06220.86
5.6.90.0110.05320.84
5.6.80.0120.04020.41
5.6.70.0040.04620.27
5.6.60.0070.04620.18
5.6.50.0100.03820.24
5.6.40.0040.04420.34
5.6.30.0090.05320.13
5.6.20.0070.04720.22
5.6.10.0090.05220.25
5.6.00.0160.03520.36
5.5.380.0190.07117.50
5.5.370.0070.06617.46
5.5.360.0070.04617.42
5.5.350.0100.07117.40
5.5.340.0040.08417.95
5.5.330.0030.06818.05
5.5.320.0060.04218.04
5.5.310.0100.07318.04
5.5.300.0070.04318.04
5.5.290.0030.04417.99
5.5.280.0100.04217.86
5.5.270.0100.03718.02
5.5.260.0070.04318.00
5.5.250.0100.03717.89
5.5.240.0070.04017.33
5.5.230.0030.04317.09
5.5.220.0100.08117.38
5.5.210.0040.04617.23
5.5.200.0150.03317.34
5.5.190.0030.04417.29
5.5.180.0100.04017.09
5.5.160.0030.04117.19
5.5.150.0030.04117.46
5.5.140.0130.03517.38
5.5.130.0100.07517.34
5.5.120.0000.05317.29
5.5.110.0030.04417.36
5.5.100.0070.03917.32
5.5.90.0300.02717.26
5.5.80.0040.04317.28
5.5.70.0070.04016.96
5.5.60.0070.04417.21
5.5.50.0160.03517.27
5.5.40.0130.05617.21
5.5.30.0160.03017.28
5.5.20.0070.03717.30
5.5.10.0130.04216.95
5.5.00.0070.04517.24
5.4.450.0160.06219.27
5.4.440.0000.04819.27
5.4.430.0030.06919.18
5.4.420.0070.07819.34
5.4.410.0060.04419.27
5.4.400.0030.04418.83
5.4.390.0130.03519.04
5.4.380.0000.04518.86
5.4.370.0070.03918.85
5.4.360.0100.07518.98
5.4.350.0070.03918.88
5.4.340.0070.04119.02
5.4.320.0120.03319.08
5.4.310.0060.03818.82
5.4.300.0030.04118.91
5.4.290.0000.04919.14
5.4.280.0030.05919.01
5.4.270.0040.04619.00
5.4.260.0000.04418.88
5.4.250.0060.03918.97
5.4.240.0040.03918.97
5.4.230.0070.04018.83
5.4.220.0070.04419.13
5.4.210.0160.05619.00
5.4.200.0070.04519.06
5.4.190.0070.03719.04
5.4.180.0000.05319.03
5.4.170.0130.03619.03
5.4.160.0000.04219.04
5.4.150.0070.09318.96
5.4.140.0060.05016.54
5.4.130.0060.03516.71
5.4.120.0070.03716.43
5.4.110.0070.04316.73
5.4.100.0030.04116.55
5.4.90.0000.04616.69
5.4.80.0000.04016.65
5.4.70.0130.05316.62
5.4.60.0100.03816.43
5.4.50.0030.03816.73
5.4.40.0100.05916.70
5.4.30.0070.07016.43
5.4.20.0000.04216.68
5.4.10.0210.04216.45
5.4.00.0070.03816.43
5.3.290.0040.04316.43
5.3.280.0060.03916.43
5.3.270.0030.04716.43
5.3.260.0040.06316.43
5.3.250.0070.04116.43
5.3.240.0130.03216.43
5.3.230.0030.04416.43
5.3.220.0070.03816.43
5.3.210.0030.04416.43
5.3.200.0070.03916.43
5.3.190.0090.03416.43
5.3.180.0060.03716.43
5.3.170.0040.05016.43
5.3.160.0000.04316.43
5.3.150.0090.03316.43
5.3.140.0090.03416.43
5.3.130.0000.05316.43
5.3.120.0070.09016.43
5.3.110.0060.04516.43
5.3.100.0100.04216.43
5.3.90.0160.02816.43
5.3.80.0130.06416.43
5.3.70.0160.05216.43
5.3.60.0150.03116.43
5.3.50.0100.04216.43
5.3.40.0070.04216.43
5.3.30.0030.04116.43
5.3.20.0070.03616.43
5.3.10.0030.03516.43
5.3.00.0070.03416.43
5.2.170.0160.06916.43
5.2.160.0040.03216.43
5.2.150.0160.02316.43
5.2.140.0060.03116.43
5.2.130.0090.02516.43
5.2.120.0000.03616.43
5.2.110.0100.02416.43
5.2.100.0070.05116.43
5.2.90.0070.03016.43
5.2.80.0060.04016.43
5.2.70.0060.02916.43
5.2.60.0100.02516.43
5.2.50.0100.04016.43
5.2.40.0070.02816.43
5.2.30.0070.02616.43
5.2.20.0070.03116.43
5.2.10.0040.02916.43
5.2.00.0100.02416.43
5.1.60.0070.04716.43
5.1.50.0060.02616.43
5.1.40.0060.03016.43
5.1.30.0140.02016.43
5.1.20.0030.03816.43
5.1.10.0000.02916.43
5.1.00.0040.02616.43
5.0.50.0080.01916.43
5.0.40.0000.04416.43
5.0.30.0040.03916.43
5.0.20.0000.02316.43
5.0.10.0000.02316.43
5.0.00.0070.06416.43
4.4.90.0030.01916.43
4.4.80.0030.01816.43
4.4.70.0030.01716.43
4.4.60.0000.02016.43
4.4.50.0040.01516.43
4.4.40.0030.05516.43
4.4.30.0100.01416.43
4.4.20.0030.01616.43
4.4.10.0030.01516.43
4.4.00.0030.02816.43
4.3.110.0000.02416.43
4.3.100.0000.01816.43
4.3.90.0000.01716.43
4.3.80.0000.02816.43
4.3.70.0030.02716.43
4.3.60.0030.02716.43
4.3.50.0030.02016.43
4.3.40.0060.02216.43
4.3.30.0030.03516.43
4.3.20.0050.01316.43
4.3.10.0000.01916.43
4.3.00.0000.01716.43

preferences:
46.53 ms | 401 KiB | 5 Q