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; $newcode = "array("; $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 == "]" && $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.60.0090.00918.50
8.3.50.0120.00718.30
8.3.40.0120.00618.93
8.3.30.0060.00918.55
8.3.20.0050.00318.90
8.3.10.0040.00418.86
8.3.00.0000.00819.13
8.2.180.0130.01016.50
8.2.170.0040.01122.96
8.2.160.0070.01018.91
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0070.00320.62
8.2.110.0090.00020.96
8.2.100.0090.00317.84
8.2.90.0040.00420.07
8.2.80.0030.00618.16
8.2.70.0030.00617.75
8.2.60.0040.00417.93
8.2.50.0050.00317.93
8.2.40.0050.00519.35
8.2.30.0040.00417.70
8.2.20.0080.00017.70
8.2.10.0040.00417.65
8.2.00.0000.00717.72
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0060.00317.66
8.1.230.0080.00320.93
8.1.220.0040.00417.74
8.1.210.0100.00018.77
8.1.200.0000.00917.23
8.1.190.0050.00317.23
8.1.180.0050.00318.10
8.1.170.0040.00417.62
8.1.160.0000.00719.06
8.1.150.0080.00018.69
8.1.140.0000.00817.34
8.1.130.0040.00417.81
8.1.120.0040.00417.38
8.1.110.0040.00417.46
8.1.100.0070.00017.45
8.1.90.0060.00317.50
8.1.80.0000.00817.53
8.1.70.0000.00717.48
8.1.60.0000.00817.52
8.1.50.0040.00417.43
8.1.40.0040.00417.55
8.1.30.0090.00017.68
8.1.20.0030.00617.71
8.1.10.0050.00317.54
8.1.00.0000.00717.47
8.0.300.0070.00020.05
8.0.290.0060.00316.75
8.0.280.0000.00818.54
8.0.270.0070.00017.30
8.0.260.0000.00716.79
8.0.250.0030.00617.03
8.0.240.0040.00416.98
8.0.230.0050.00316.98
8.0.220.0040.00416.84
8.0.210.0040.00416.96
8.0.200.0030.00316.98
8.0.190.0040.00416.99
8.0.180.0040.00416.93
8.0.170.0040.00416.80
8.0.160.0070.00016.82
8.0.150.0060.00316.77
8.0.140.0030.00616.89
8.0.130.0000.00613.41
8.0.120.0040.00716.90
8.0.110.0040.00416.81
8.0.100.0000.00717.00
8.0.90.0030.00516.84
8.0.80.0070.00816.88
8.0.70.0080.00016.96
8.0.60.0000.00716.73
8.0.50.0000.00716.73
8.0.30.0060.00917.09
8.0.20.0140.00817.33
8.0.10.0040.00416.98
8.0.00.0090.01016.90
7.4.330.0050.00013.09
7.4.320.0030.00316.70
7.4.300.0020.00516.66
7.4.290.0000.00716.46
7.4.280.0030.00516.64
7.4.270.0070.00016.68
7.4.260.0030.00313.29
7.4.250.0000.00816.53
7.4.240.0070.00016.65
7.4.230.0030.00316.55
7.4.220.0090.00916.58
7.4.210.0070.00816.66
7.4.200.0000.00716.56
7.4.190.0070.00016.75
7.4.160.0080.00816.60
7.4.150.0080.01116.48
7.4.140.0170.00916.65
7.4.130.0090.00916.62
7.4.120.0120.00616.54
7.4.110.0030.01616.62
7.4.100.0070.01016.59
7.4.90.0110.00716.53
7.4.80.0160.00419.39
7.4.70.0030.01316.66
7.4.60.0060.01216.52
7.4.50.0060.00616.38
7.4.40.0110.00716.68
7.4.30.0060.01116.56
7.4.00.0070.00414.91
7.3.330.0000.00713.37
7.3.320.0050.00213.28
7.3.310.0040.00416.43
7.3.300.0030.00316.38
7.3.290.0080.00716.37
7.3.280.0110.00916.39
7.3.270.0080.01116.40
7.3.260.0090.01516.34
7.3.250.0130.00516.50
7.3.240.0070.01016.34
7.3.230.0110.00616.59
7.3.210.0110.00716.42
7.3.200.0060.01016.36
7.3.190.0060.01216.41
7.3.180.0120.00616.28
7.3.170.0160.00316.45
7.3.160.0150.00316.56
7.3.120.0110.00715.22
7.2.330.0100.01316.82
7.2.320.0120.00616.73
7.2.310.0100.01016.84
7.2.300.0070.01016.86
7.2.290.0030.01416.92
7.2.00.0030.00919.16
7.1.100.0090.00318.25
7.1.70.0080.00317.09
7.1.60.0070.02019.30
7.1.50.0070.01316.86
7.1.00.0000.08022.31
7.0.200.0090.00316.66
7.0.140.0070.07022.18
7.0.120.0100.06322.06
7.0.60.0100.07319.87
7.0.50.0030.07017.95
7.0.40.0130.07020.01
7.0.30.0270.07720.09
7.0.20.0230.08720.30
7.0.10.0130.08320.20
7.0.00.0130.06320.11
5.6.280.0130.06321.13
5.6.210.0030.08320.65
5.6.200.0030.05018.18
5.6.190.0100.04020.60
5.6.180.0430.07020.61
5.6.170.0370.07320.62
5.6.160.0030.09020.49
5.6.150.0070.05318.22
5.6.140.0030.05718.12
5.6.130.0030.08318.17
5.6.120.0070.04321.13
5.6.110.0030.07320.92
5.6.100.0030.07321.05
5.6.90.0130.03320.96
5.6.80.0130.04720.43
5.5.350.0100.08020.47
5.5.340.0030.04018.02
5.5.330.0000.04320.20
5.5.320.0170.04320.30
5.5.310.0230.03720.27
5.5.300.0070.08317.92
5.5.290.0030.08318.00
5.5.280.0070.08720.94
5.5.270.0070.03720.68
5.5.260.0100.07320.80
5.5.250.0130.07720.62
5.5.240.0170.05720.16
5.4.450.0100.07319.50
5.4.440.0130.03719.52
5.4.430.0130.06719.48
5.4.420.0070.07319.40
5.4.410.0170.05019.28
5.4.400.0070.07718.81
5.4.390.0070.03718.79
5.4.380.0070.07719.18
5.4.370.0100.07319.14
5.4.360.0170.06318.80
5.4.350.0100.07318.79
5.4.340.0130.07018.92
5.4.320.0100.05318.93
5.4.310.0070.07719.10
5.4.300.0030.07718.78
5.4.290.0030.06718.80
5.4.280.0100.07019.13
5.4.270.0070.05019.14
5.4.260.0100.07719.10
5.4.250.0100.04018.78
5.4.240.0070.05319.00
5.4.230.0130.06318.92
5.4.220.0070.07019.07
5.4.210.0070.05018.80
5.4.200.0100.04318.91
5.4.190.0100.07319.07
5.4.180.0000.08019.07
5.4.170.0070.05018.92
5.4.160.0170.05318.77
5.4.150.0030.04719.05
5.4.140.0000.04316.41
5.4.130.0170.06316.39
5.4.120.0000.04716.29
5.4.110.0030.04016.46
5.4.100.0030.05716.46
5.4.90.0100.07016.20
5.4.80.0100.08016.28
5.4.70.0000.07316.44
5.4.60.0070.05716.63
5.4.50.0000.04016.41
5.4.40.0070.05016.29
5.4.30.0100.06716.39
5.4.20.0070.07316.30
5.4.10.0170.03016.35
5.4.00.0070.07015.72
5.3.290.0130.07014.57
5.3.280.0030.04014.58
5.3.270.0130.07014.77
5.3.260.0100.06014.76
5.3.250.0030.04014.55
5.3.240.0000.06714.46
5.3.230.0070.03714.61
5.3.220.0100.07314.56
5.3.210.0030.06714.53
5.3.200.0070.07714.51
5.3.190.0000.08314.59
5.3.180.0130.06714.58
5.3.170.0030.04314.72
5.3.160.0030.07714.53
5.3.150.0030.06014.58
5.3.140.0030.03714.55
5.3.130.0070.04014.54
5.3.120.0000.06714.55
5.3.110.0130.07014.55
5.3.100.0130.04014.03
5.3.90.0100.03713.97
5.3.80.0030.03713.88
5.3.70.0100.03014.03
5.3.60.0000.07713.89
5.3.50.0070.05713.94
5.3.40.0100.07314.00
5.3.30.0030.04013.82
5.3.20.0030.04013.69
5.3.10.0100.03013.65
5.3.00.0100.03013.64
5.2.170.0000.04011.16
5.2.160.0070.02711.16
5.2.150.0100.03311.21
5.2.140.0030.03011.11
5.2.130.0070.04711.14
5.2.120.0000.05311.11
5.2.110.0100.03011.11
5.2.100.0000.03311.11
5.2.90.0070.02711.11
5.2.80.0100.05011.18
5.2.70.0000.04311.34
5.2.60.0000.04711.00
5.2.50.0070.03310.97
5.2.40.0030.04011.05
5.2.30.0030.03711.00
5.2.20.0030.05310.96
5.2.10.0000.03010.91
5.2.00.0070.05710.63
5.1.60.0030.04010.21
5.1.50.0030.05010.04
5.1.40.0000.03010.11
5.1.30.0030.02710.55
5.1.20.0070.05010.45
5.1.10.0030.05010.12
5.1.00.0070.0439.98
5.0.50.0070.0379.56
5.0.40.0030.0479.56
5.0.30.0000.0639.56
5.0.20.0100.0409.56
5.0.10.0000.0379.56
5.0.00.0070.0609.56
4.4.90.0000.0209.56
4.4.80.0000.0309.56
4.4.70.0000.0409.56
4.4.60.0030.0279.56
4.4.50.0030.0339.56
4.4.40.0000.0409.56
4.4.30.0000.0409.56
4.4.20.0000.0379.56
4.4.10.0070.0179.56
4.4.00.0030.0579.56
4.3.110.0100.0309.56
4.3.100.0000.0209.56
4.3.90.0000.0339.56
4.3.80.0030.0509.56
4.3.70.0000.0379.56
4.3.60.0000.0279.56
4.3.50.0070.0279.56
4.3.40.0070.0479.56
4.3.30.0000.0309.56
4.3.20.0000.0279.56
4.3.10.0000.0409.56
4.3.00.0000.0339.56

preferences:
45.32 ms | 401 KiB | 5 Q