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 == ")") || ($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.0100.01016.63
8.3.50.0100.00621.95
8.3.40.0140.00418.80
8.3.30.0000.01419.07
8.3.20.0070.00020.34
8.3.10.0000.00723.52
8.3.00.0030.00719.15
8.2.180.0030.01618.21
8.2.170.0120.00322.96
8.2.160.0100.00320.32
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0050.00322.15
8.2.110.0090.00022.24
8.2.100.0090.00318.03
8.2.90.0040.00418.95
8.2.80.0050.00317.97
8.2.70.0000.00917.61
8.2.60.0050.00318.04
8.2.50.0080.00018.07
8.2.40.0050.00318.22
8.2.30.0030.00518.22
8.2.20.0050.00317.81
8.2.10.0000.00818.06
8.2.00.0040.00717.77
8.1.280.0090.00625.92
8.1.270.0180.00322.09
8.1.260.0040.00426.35
8.1.250.0030.00628.09
8.1.240.0060.00323.98
8.1.230.0000.01219.01
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0090.00017.23
8.1.190.0000.00817.53
8.1.180.0000.00918.10
8.1.170.0000.00818.56
8.1.160.0030.00521.96
8.1.150.0040.00418.63
8.1.140.0000.00717.51
8.1.130.0030.00317.87
8.1.120.0000.00717.43
8.1.110.0000.00717.41
8.1.100.0080.00017.51
8.1.90.0020.00517.56
8.1.80.0000.01017.43
8.1.70.0070.00017.39
8.1.60.0000.00817.58
8.1.50.0000.00817.55
8.1.40.0060.00317.44
8.1.30.0030.00517.55
8.1.20.0040.00417.61
8.1.10.0000.00717.63
8.1.00.0050.00317.57
8.0.300.0040.00419.09
8.0.290.0000.00717.18
8.0.280.0030.00318.48
8.0.270.0040.00417.18
8.0.260.0000.00817.31
8.0.250.0030.00316.98
8.0.240.0040.00417.04
8.0.230.0000.00717.02
8.0.220.0000.00716.88
8.0.210.0000.00716.90
8.0.200.0070.00416.98
8.0.190.0090.00016.91
8.0.180.0040.00416.91
8.0.170.0000.00716.85
8.0.160.0050.00216.89
8.0.150.0050.00316.87
8.0.140.0050.00216.98
8.0.130.0050.00013.30
8.0.120.0050.00316.89
8.0.110.0030.00616.95
8.0.100.0040.00416.77
8.0.90.0000.00716.97
8.0.80.0000.01516.83
8.0.70.0040.00417.05
8.0.60.0000.00717.01
8.0.50.0050.00316.82
8.0.30.0100.01017.05
8.0.20.0080.01117.43
8.0.10.0040.00417.18
8.0.00.0140.00416.64
7.4.330.0050.00015.09
7.4.320.0060.00016.57
7.4.300.0060.00016.55
7.4.290.0000.00716.67
7.4.280.0000.00716.45
7.4.270.0030.00316.56
7.4.260.0000.00816.39
7.4.250.0050.00316.50
7.4.240.0040.00416.62
7.4.230.0000.00716.39
7.4.220.0120.00616.68
7.4.210.0080.01016.67
7.4.200.0030.00316.76
7.4.190.0040.00416.80
7.4.160.0170.00016.36
7.4.150.0180.00017.40
7.4.140.0070.01017.86
7.4.130.0080.00916.57
7.4.120.0090.00816.53
7.4.110.0140.00316.44
7.4.100.0160.00616.47
7.4.90.0150.00916.58
7.4.80.0160.00319.39
7.4.70.0090.00816.66
7.4.60.0150.00616.36
7.4.50.0030.00616.38
7.4.40.0110.00322.77
7.4.30.0080.00816.65
7.4.00.0120.00514.95
7.3.330.0000.00513.32
7.3.320.0030.00313.22
7.3.310.0000.00716.35
7.3.300.0040.00416.38
7.3.290.0030.01616.36
7.3.280.0130.00316.40
7.3.270.0100.00717.40
7.3.260.0090.01216.34
7.3.250.0110.00816.54
7.3.240.0060.01216.38
7.3.230.0110.00716.60
7.3.210.0100.01316.59
7.3.200.0040.01919.39
7.3.190.0110.00716.44
7.3.180.0130.00316.61
7.3.170.0060.01516.37
7.3.160.0030.01416.38
7.3.120.0100.00614.76
7.3.110.0060.01014.87
7.3.100.0070.00314.63
7.3.90.0080.00314.72
7.3.80.0000.01314.88
7.3.70.0060.00314.73
7.3.60.0000.01414.60
7.3.50.0070.01114.88
7.3.40.0000.01414.91
7.3.30.0040.01114.66
7.3.20.0000.01116.70
7.3.10.0040.01116.67
7.3.00.0090.00416.77
7.2.330.0030.01316.46
7.2.320.0090.00616.67
7.2.310.0110.01116.84
7.2.300.0090.00916.96
7.2.290.0100.01316.77
7.2.250.0070.00715.30
7.2.240.0090.00915.12
7.2.230.0050.00915.25
7.2.220.0070.00714.93
7.2.210.0090.00615.05
7.2.200.0070.00315.26
7.2.190.0030.01314.96
7.2.180.0000.01515.02
7.2.170.0120.00015.18
7.2.130.0000.01416.95
7.2.120.0090.00917.04
7.2.110.0000.01216.98
7.2.100.0040.00717.11
7.2.90.0030.00717.06
7.2.80.0040.01216.87
7.2.70.0070.00316.84
7.2.60.0030.00917.08
7.2.50.0100.00616.91
7.2.40.0040.00717.04
7.2.30.0000.01617.04
7.2.20.0030.01016.84
7.2.10.0000.01116.74
7.2.00.0030.01318.20
7.1.330.0100.00715.87
7.1.320.0060.01015.77
7.1.310.0120.00316.11
7.1.300.0160.00015.67
7.1.290.0000.01315.93
7.1.280.0060.00315.94
7.1.270.0000.01315.89
7.1.260.0040.01115.77
7.1.250.0080.00415.69
7.1.100.0040.00718.21
7.1.70.0040.00817.30
7.1.60.0100.01019.33
7.1.50.0140.01134.77
7.1.00.0030.07322.30
7.0.200.0000.00716.88
7.0.140.0030.07321.97
7.0.110.0100.04720.11
7.0.100.0300.04019.88
7.0.90.0130.06019.96
7.0.80.0100.04020.07
7.0.70.0100.03719.88
7.0.60.0100.04019.97
7.0.50.0100.03320.12
7.0.40.0070.04719.75
7.0.30.0030.04019.65
7.0.20.0000.05719.78
7.0.10.0070.07719.73
7.0.00.0100.03319.72
5.6.280.0000.07320.86
5.6.260.0030.05020.65
5.6.250.0130.06720.93
5.6.240.0030.08720.76
5.6.230.0030.04320.74
5.6.220.0000.06720.67
5.6.210.0000.04320.67
5.6.200.0030.04020.69
5.6.190.0130.03320.72
5.6.180.0030.06020.75
5.6.170.0000.04320.65
5.6.160.0030.03720.59
5.6.150.0130.08020.68
5.6.140.0130.07320.74
5.6.130.0070.07320.65
5.6.120.0070.04020.71
5.6.110.0000.04320.88
5.6.100.0070.06320.83
5.6.90.0100.06320.61
5.6.80.0070.06320.28
5.6.70.0030.06320.08
5.6.60.0070.09719.87
5.6.50.0070.03320.13
5.6.40.0070.04720.25
5.6.30.0100.04719.98
5.6.20.0070.04720.05
5.6.10.0070.04319.98
5.6.00.0030.05319.99
5.5.380.0100.07317.63
5.5.370.0000.04317.63
5.5.360.0100.05717.49
5.5.350.0070.05717.60
5.5.340.0000.05317.89
5.5.330.0130.05317.87
5.5.320.0030.03718.16
5.5.310.0000.04318.13
5.5.300.0030.09717.88
5.5.290.0030.06017.89
5.5.280.0070.03317.86
5.5.270.0100.03718.12
5.5.260.0030.04017.86
5.5.250.0070.05717.67
5.5.240.0100.04017.53
5.5.230.0070.08017.26
5.5.220.0170.04317.63
5.5.210.0070.04317.53
5.5.200.0030.03717.48
5.5.190.0030.04717.45
5.5.180.0070.05317.24
5.5.160.0070.03317.27
5.5.150.0000.05317.23
5.5.140.0000.05017.33
5.5.130.0030.03717.36
5.5.120.0130.06017.51
5.5.110.0000.06717.50
5.5.100.0030.04017.12
5.5.90.0100.07317.13
5.5.80.0070.07017.30
5.5.70.0030.03717.12
5.5.60.0130.05317.22
5.5.50.0070.03317.13
5.5.40.0030.05717.33
5.5.30.0030.03017.39
5.5.20.0070.03317.37
5.5.10.0070.06317.03
5.5.00.0030.06717.12
5.4.450.0030.08319.46
5.4.440.0000.04319.32
5.4.430.0130.04319.32
5.4.420.0000.04719.27
5.4.410.0100.04019.36
5.4.400.0030.05018.95
5.4.390.0070.06718.98
5.4.380.0000.04018.93
5.4.370.0030.04018.93
5.4.360.0030.04019.12
5.4.350.0100.03019.27
5.4.340.0100.03019.18
5.4.320.0000.04019.25
5.4.310.0070.04019.00
5.4.300.0030.03318.94
5.4.290.0030.03318.98
5.4.280.0070.06718.95
5.4.270.0070.03018.95
5.4.260.0100.05019.18
5.4.250.0000.08319.02
5.4.240.0030.06319.02
5.4.230.0130.03019.00
5.4.220.0030.07019.24
5.4.210.0030.05719.11
5.4.200.0100.06019.20
5.4.190.0000.03319.27
5.4.180.0070.03318.99
5.4.170.0070.07319.17
5.4.160.0030.03719.00
5.4.150.0070.03718.98
5.4.140.0070.07316.55
5.4.130.0030.06016.58
5.4.120.0030.06716.54
5.4.110.0030.04716.33
5.4.100.0030.04716.53
5.4.90.0130.05316.55
5.4.80.0000.03716.32
5.4.70.0000.04016.23
5.4.60.0000.04016.55
5.4.50.0030.04316.54
5.4.40.0030.07316.47
5.4.30.0000.04016.39
5.4.20.0000.03316.51
5.4.10.0000.05016.43
5.4.00.0030.03716.02
5.3.290.0070.07014.66
5.3.280.0030.03714.68
5.3.270.0070.03314.56
5.3.260.0000.05714.53
5.3.250.0070.06314.57
5.3.240.0070.07314.54
5.3.230.0070.07014.45
5.3.220.0100.06714.53
5.3.210.0000.07014.51
5.3.200.0030.06714.46
5.3.190.0070.03314.63
5.3.180.0070.03014.63
5.3.170.0030.03714.53
5.3.160.0130.02714.64
5.3.150.0000.07314.42
5.3.140.0070.05314.52
5.3.130.0070.07314.52
5.3.120.0030.03714.46
5.3.110.0000.03714.61
5.3.100.0000.04014.03
5.3.90.0030.03714.15
5.3.80.0000.03714.18
5.3.70.0070.03314.02
5.3.60.0070.03714.00
5.3.50.0030.04313.88
5.3.40.0200.02013.86
5.3.30.0100.03313.86
5.3.20.0070.03313.71
5.3.10.0070.02713.55
5.3.00.0000.04713.65
5.2.170.0000.03012.01
5.2.160.0030.06712.01
5.2.150.0030.02712.01
5.2.140.0030.03012.01
5.2.130.0000.06312.01
5.2.120.0000.03312.01
5.2.110.0100.02712.01
5.2.100.0070.03012.01
5.2.90.0000.04012.01
5.2.80.0030.02712.01
5.2.70.0030.05712.01
5.2.60.0030.03712.01
5.2.50.0030.03012.01
5.2.40.0070.03012.01
5.2.30.0070.02312.01
5.2.20.0030.05312.01
5.2.10.0070.04012.01
5.2.00.0000.03012.01
5.1.60.0070.03712.01
5.1.50.0030.03712.01
5.1.40.0030.02312.01
5.1.30.0070.02312.01
5.1.20.0070.03712.01
5.1.10.0000.03012.01
5.1.00.0000.02312.01
5.0.50.0070.01712.01
5.0.40.0000.03712.01
5.0.30.0030.04312.01
5.0.20.0000.01712.01
5.0.10.0030.01712.01
5.0.00.0000.03312.01
4.4.90.0030.02012.01
4.4.80.0000.01712.01
4.4.70.0000.01712.01
4.4.60.0030.01712.01
4.4.50.0100.02712.01
4.4.40.0070.03312.01
4.4.30.0000.01712.01
4.4.20.0030.02712.01
4.4.10.0000.01712.01
4.4.00.0000.02712.01
4.3.110.0000.02012.01
4.3.100.0000.02012.01
4.3.90.0000.01712.01
4.3.80.0000.02312.01
4.3.70.0070.02312.01
4.3.60.0000.02312.01
4.3.50.0000.01712.01
4.3.40.0030.04712.01
4.3.30.0030.01712.01
4.3.20.0030.01712.01
4.3.10.0000.03712.01
4.3.00.0030.01012.01

preferences:
42.59 ms | 401 KiB | 5 Q