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); $i = 0; while (++$i < count($token)) { // enter into array; then start. if ($token[$i] == "(") { $newcode = "array("; $ending = ")"; break; } if ($token[$i] == "[") { $newcode = "["; $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.0130.00718.43
8.3.50.0080.01021.92
8.3.40.0000.01518.84
8.3.30.0150.00618.67
8.3.20.0090.00018.73
8.3.10.0080.00021.09
8.3.00.0060.00321.95
8.2.180.0040.01116.88
8.2.170.0090.00622.96
8.2.160.0120.00321.24
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00021.00
8.2.110.0000.00920.48
8.2.100.0060.00617.86
8.2.90.0040.00419.35
8.2.80.0040.00417.97
8.2.70.0030.00617.47
8.2.60.0060.00317.91
8.2.50.0040.00418.07
8.2.40.0060.00318.16
8.2.30.0040.00419.52
8.2.20.0000.00817.69
8.2.10.0000.00717.74
8.2.00.0000.00917.78
8.1.280.0110.00425.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.11
8.1.230.0060.00617.42
8.1.220.0090.00017.74
8.1.210.0040.00418.77
8.1.200.0070.00317.36
8.1.190.0040.00417.39
8.1.180.0030.00618.10
8.1.170.0000.00818.64
8.1.160.0060.00318.89
8.1.150.0000.00818.73
8.1.140.0000.00717.38
8.1.130.0000.00717.81
8.1.120.0000.00717.41
8.1.110.0080.00017.42
8.1.100.0050.00217.54
8.1.90.0020.00517.47
8.1.80.0030.00517.52
8.1.70.0030.00317.49
8.1.60.0000.00817.59
8.1.50.0070.00017.55
8.1.40.0000.00817.63
8.1.30.0000.00817.59
8.1.20.0000.00817.70
8.1.10.0060.00317.51
8.1.00.0090.00317.51
8.0.300.0000.00818.77
8.0.290.0080.00016.88
8.0.280.0040.00418.49
8.0.270.0000.00717.21
8.0.260.0040.00218.50
8.0.250.0040.00416.90
8.0.240.0040.00416.96
8.0.230.0000.00717.01
8.0.220.0000.00716.83
8.0.210.0000.00717.00
8.0.200.0030.00317.00
8.0.190.0040.00416.96
8.0.180.0070.00016.98
8.0.170.0000.00716.87
8.0.160.0070.00016.96
8.0.150.0030.00616.95
8.0.140.0040.00416.93
8.0.130.0030.00313.34
8.0.120.0040.00416.92
8.0.110.0000.00816.91
8.0.100.0050.00216.76
8.0.90.0050.00216.96
8.0.80.0060.00916.89
8.0.70.0000.00716.83
8.0.60.0000.00716.73
8.0.50.0080.00016.81
8.0.30.0080.01017.21
8.0.20.0100.01317.40
8.0.10.0030.00617.00
8.0.00.0130.00516.90
7.4.330.0000.00616.69
7.4.320.0040.00416.48
7.4.300.0030.00316.69
7.4.290.0070.00016.46
7.4.280.0030.00516.59
7.4.270.0070.00016.64
7.4.260.0050.00013.28
7.4.250.0070.00016.59
7.4.240.0040.00416.68
7.4.230.0070.00016.67
7.4.220.0120.00316.56
7.4.210.0070.00916.60
7.4.200.0000.00716.66
7.4.190.0000.00816.59
7.4.160.0070.01716.57
7.4.150.0110.00717.40
7.4.140.0130.00817.86
7.4.130.0070.01016.48
7.4.120.0070.01316.63
7.4.110.0100.00716.31
7.4.100.0100.00716.60
7.4.90.0150.00316.39
7.4.80.0080.01119.39
7.4.70.0070.01716.70
7.4.60.0070.01016.70
7.4.50.0090.00016.64
7.4.40.0030.01322.77
7.4.30.0080.00816.68
7.4.10.0080.01115.03
7.4.00.0080.00715.11
7.3.330.0050.00013.27
7.3.320.0050.00013.25
7.3.310.0030.00416.32
7.3.300.0000.00716.41
7.3.290.0090.00616.38
7.3.280.0100.00616.35
7.3.270.0140.00317.40
7.3.260.0090.00818.24
7.3.250.0120.00916.42
7.3.240.0070.01016.60
7.3.230.0070.01016.39
7.3.210.0030.01416.42
7.3.200.0110.01219.39
7.3.190.0090.01616.55
7.3.180.0090.00916.69
7.3.170.0080.00816.58
7.3.160.0080.00816.63
7.3.130.0070.01114.63
7.3.120.0080.00815.03
7.3.110.0080.00815.16
7.3.100.0000.01514.83
7.3.90.0030.01414.79
7.3.80.0100.00014.98
7.3.70.0040.01114.97
7.3.60.0060.00614.79
7.3.50.0040.01114.82
7.3.40.0110.00015.00
7.3.30.0000.01314.89
7.3.20.0070.01116.64
7.3.10.0030.00616.49
7.3.00.0060.00616.56
7.2.330.0090.00916.55
7.2.320.0070.01016.77
7.2.310.0060.01516.76
7.2.300.0060.01016.90
7.2.290.0080.00816.64
7.2.260.0070.01015.02
7.2.250.0060.01214.99
7.2.240.0090.00615.29
7.2.230.0110.00715.00
7.2.220.0030.01415.12
7.2.210.0030.00615.31
7.2.200.0030.01015.16
7.2.190.0000.01315.26
7.2.180.0040.00714.90
7.2.170.0070.00715.20
7.2.160.0070.01114.77
7.2.150.0100.00717.16
7.2.140.0060.00617.20
7.2.130.0070.00716.88
7.2.120.0000.00916.83
7.2.110.0030.00716.76
7.2.100.0060.00917.08
7.2.90.0040.01417.15
7.2.80.0100.00017.15
7.2.70.0090.00616.68
7.2.60.0030.01516.85
7.2.50.0070.00717.09
7.2.40.0040.01117.16
7.2.30.0040.01116.98
7.2.20.0090.00317.05
7.2.10.0110.00416.79
7.2.00.0020.01218.34
7.1.330.0030.00815.79
7.1.320.0110.00415.52
7.1.310.0000.01415.71
7.1.300.0030.00915.72
7.1.290.0040.00715.76
7.1.280.0030.01215.87
7.1.270.0080.00515.87
7.1.260.0030.00615.81
7.1.250.0120.00015.69
7.1.240.0000.01415.61
7.1.230.0060.00915.86
7.1.220.0090.00315.86
7.1.210.0000.00915.96
7.1.200.0070.00515.68
7.1.190.0040.01115.95
7.1.180.0030.00615.90
7.1.170.0060.00616.02
7.1.160.0070.00715.74
7.1.150.0070.00715.59
7.1.140.0030.01015.61
7.1.130.0070.00715.91
7.1.120.0160.00315.94
7.1.110.0060.01215.71
7.1.100.0590.00316.05
7.1.90.0080.00615.81
7.1.80.0070.00715.85
7.1.70.0030.00616.46
7.1.60.0050.01717.63
7.1.50.0060.01116.43
7.1.40.0100.00315.76
7.1.30.0090.00615.83
7.1.20.0030.01015.92
7.1.10.0100.00315.79
7.1.00.0020.02919.14
7.0.330.0030.00815.59
7.0.320.0100.00315.50
7.0.310.0060.00915.44
7.0.300.0030.00615.50
7.0.290.0070.00715.63
7.0.280.0040.01115.49
7.0.270.0070.00715.18
7.0.260.0090.00615.31
7.0.250.0090.00915.29
7.0.240.0070.00715.33
7.0.230.0100.00315.35
7.0.220.0070.00715.38
7.0.210.0030.01015.28
7.0.200.0040.00516.04
7.0.190.0030.01015.50
7.0.180.0140.00015.21
7.0.170.0100.00315.23
7.0.160.0030.01015.46
7.0.150.0030.00715.57
7.0.140.0080.04018.78
7.0.130.0150.00015.19
7.0.120.0110.00315.39
7.0.110.0070.00415.54
7.0.100.0030.01015.40
7.0.90.0090.00315.26
7.0.80.0060.01015.43
7.0.70.0050.04818.52
7.0.60.0020.04818.51
7.0.50.0070.04718.87
7.0.40.0020.04316.75
7.0.30.0070.04516.97
7.0.20.0050.04416.76
7.0.10.0090.04016.80
7.0.00.0060.04416.78
5.6.400.0000.01014.58
5.6.390.0030.00714.47
5.6.380.0060.00614.58
5.6.370.0060.00914.31
5.6.360.0090.00614.13
5.6.350.0030.00614.13
5.6.340.0000.01014.89
5.6.330.0060.00914.63
5.6.320.0000.01814.47
5.6.310.0070.01014.58
5.6.300.0080.00814.45
5.6.290.0080.00814.79
5.6.280.0050.04217.92
5.6.270.0000.01114.47
5.6.260.0110.00014.66
5.6.250.0030.00914.65
5.6.240.0030.01314.54
5.6.230.0060.00914.49
5.6.220.0050.04317.49
5.6.210.0040.04917.57
5.6.200.0060.04517.71
5.6.190.0060.04117.67
5.6.180.0060.04617.70
5.6.170.0050.04817.78
5.6.160.0030.04717.68
5.6.150.0050.04017.96
5.6.140.0030.04217.65
5.6.130.0040.04817.79
5.6.120.0030.05217.75
5.6.110.0100.03517.73
5.6.100.0050.03717.65
5.6.90.0030.04817.87
5.6.80.0070.03817.31
5.6.70.0060.03817.36
5.6.60.0040.04317.39
5.6.50.0050.03717.43
5.6.40.0020.04417.48
5.6.30.0080.04317.51
5.6.20.0100.03817.48
5.6.10.0030.04517.50
5.6.00.0050.04317.38
5.5.380.0030.01014.62
5.5.370.0100.00614.57
5.5.360.0020.04717.50
5.5.350.0050.04717.56
5.5.340.0110.03817.67
5.5.330.0090.04017.49
5.5.320.0050.04617.65
5.5.310.0050.04617.72
5.5.300.0030.04917.67
5.5.290.0060.04117.64
5.5.280.0030.04817.55
5.5.270.0070.04217.53
5.5.260.0080.04317.63
5.5.250.0120.03317.28
5.5.240.0040.03217.36
5.5.230.0070.04317.33
5.5.220.0070.02717.41
5.5.210.0030.04517.29
5.5.200.0060.04017.23
5.5.190.0050.04017.16
5.5.180.0060.04317.27
5.5.170.0070.00714.34
5.5.160.0080.03817.29
5.5.150.0090.02717.17
5.5.140.0050.04317.27
5.5.130.0080.04017.29
5.5.120.0110.04117.28
5.5.110.0070.04217.23
5.5.100.0080.04217.04
5.5.90.0070.04217.30
5.5.80.0050.03917.19
5.5.70.0050.02517.27
5.5.60.0050.02317.24
5.5.50.0030.02517.06
5.5.40.0060.03316.95
5.5.30.0040.02117.16
5.5.20.0050.02517.27
5.5.10.0000.02617.24
5.5.00.0040.02917.36
5.4.450.0060.03815.79
5.4.440.0060.04615.78
5.4.430.0080.03815.88
5.4.420.0020.04515.78
5.4.410.0000.04615.54
5.4.400.0020.04215.44
5.4.390.0050.03315.46
5.4.380.0030.03315.47
5.4.370.0060.03815.51
5.4.360.0060.03415.57
5.4.350.0050.03815.58
5.4.340.0050.04115.58
5.4.330.0000.00612.13
5.4.320.0040.03615.60
5.4.310.0070.04015.44
5.4.300.0050.03715.53
5.4.290.0040.03615.53
5.4.280.0020.04315.53
5.4.270.0030.04015.54
5.4.260.0080.03815.51
5.4.250.0020.03115.59
5.4.240.0050.03815.50
5.4.230.0030.04015.66
5.4.220.0020.02315.57
5.4.210.0050.02315.57
5.4.200.0050.02315.62
5.4.190.0090.01915.46
5.4.180.0040.02415.50
5.4.170.0030.02215.56
5.4.160.0030.02215.58
5.4.150.0080.01815.60
5.4.140.0050.01614.25
5.4.130.0030.02014.24
5.4.120.0020.02414.23
5.4.110.0030.02214.29
5.4.100.0030.02514.25
5.4.90.0000.03714.31
5.4.80.0030.03014.21
5.4.70.0050.02514.30
5.4.60.0070.03714.21
5.4.50.0080.02214.22
5.4.40.0060.02114.28
5.4.30.0050.02014.16
5.4.20.0050.01814.17
5.4.10.0030.02014.27
5.4.00.0040.01913.92
5.3.290.0020.04313.40
5.3.280.0020.02113.32
5.3.270.0030.03813.33
5.3.260.0020.02213.38
5.3.250.0060.02213.32
5.3.240.0040.01813.33
5.3.230.0000.02313.32
5.3.220.0030.01713.37
5.3.210.0030.02313.37
5.3.200.0060.02013.37
5.3.190.0020.03713.36
5.3.180.0000.01813.37
5.3.170.0030.03113.37
5.3.160.0020.02413.36
5.3.150.0060.01813.30
5.3.140.0000.02613.28
5.3.130.0030.02813.36
5.3.120.0030.03013.29
5.3.110.0050.02113.37
5.3.100.0020.02213.09
5.3.90.0040.01913.02
5.3.80.0050.01912.98
5.3.70.0030.02313.06
5.3.60.0010.02613.07
5.3.50.0040.01913.06
5.3.40.0000.02513.04
5.3.30.0050.01713.05
5.3.20.0030.01812.94
5.3.10.0040.01712.90
5.3.00.0040.01512.85
5.2.170.0030.02311.35
5.2.160.0000.02711.35
5.2.150.0000.02311.35
5.2.140.0000.02311.35
5.2.130.0000.02311.35
5.2.120.0000.03011.35
5.2.110.0000.03011.35
5.2.100.0030.02011.35
5.2.90.0000.02711.35
5.2.80.0030.02711.35
5.2.70.0000.02311.35
5.2.60.0000.02311.35
5.2.50.0000.03011.35
5.2.40.0000.02311.35
5.2.30.0000.02711.35
5.2.20.0030.02011.35
5.2.10.0030.02011.35
5.2.00.0030.03011.35
5.1.60.0030.01711.35
5.1.50.0000.02011.35
5.1.40.0000.02311.35
5.1.30.0030.02011.35
5.1.20.0000.02311.35
5.1.10.0000.02311.35
5.1.00.0030.01711.35
5.0.50.0000.01711.35
5.0.40.0030.01311.35
5.0.30.0030.02311.35
5.0.20.0030.01711.35
5.0.10.0030.01311.35
5.0.00.0030.02311.35
4.4.90.0000.01311.35
4.4.80.0000.01311.35
4.4.70.0030.01011.35
4.4.60.0000.01311.35
4.4.50.0000.01311.35
4.4.40.0000.02011.35
4.4.30.0000.01311.35
4.4.20.0000.01311.35
4.4.10.0030.01311.35
4.4.00.0000.02311.35
4.3.110.0000.01711.35
4.3.100.0030.01311.35
4.3.90.0030.01011.35
4.3.80.0000.02011.35
4.3.70.0000.01311.35
4.3.60.0030.01311.35
4.3.50.0000.01311.35
4.3.40.0000.05311.35
4.3.30.0000.01711.35
4.3.20.0000.01311.35
4.3.10.0030.02311.35
4.3.00.0000.02011.35

preferences:
39.4 ms | 401 KiB | 5 Q