3v4l.org

run code in 300+ PHP versions simultaneously
<?php $code='array("aaa", "sdsd" => "dsdsd");'; // fail $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.0120.00316.75
8.3.50.0070.01321.98
8.3.40.0070.01118.65
8.3.30.0000.01419.18
8.3.20.0050.00320.25
8.3.10.0060.00323.66
8.3.00.0040.00422.44
8.2.180.0090.00916.75
8.2.170.0090.00622.96
8.2.160.0070.01122.29
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0050.00226.16
8.2.120.0000.00722.25
8.2.110.0090.00022.27
8.2.100.0040.00818.03
8.2.90.0050.00319.30
8.2.80.0040.00417.97
8.2.70.0120.00017.63
8.2.60.0040.00417.80
8.2.50.0040.00418.07
8.2.40.0110.00319.17
8.2.30.0000.00818.23
8.2.20.0080.00017.82
8.2.10.0070.00017.91
8.2.00.0040.00417.74
8.1.280.0150.00025.92
8.1.270.0090.00023.78
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00723.91
8.1.230.0120.00019.07
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00617.48
8.1.190.0000.00817.40
8.1.180.0030.00618.10
8.1.170.0030.00618.65
8.1.160.0000.00722.14
8.1.150.0080.00018.77
8.1.140.0050.00217.42
8.1.130.0000.00717.92
8.1.120.0040.00417.49
8.1.110.0000.00717.50
8.1.100.0000.00817.43
8.1.90.0000.00717.45
8.1.80.0030.00317.41
8.1.70.0000.00717.46
8.1.60.0060.00317.53
8.1.50.0030.00517.56
8.1.40.0040.00417.43
8.1.30.0030.00517.65
8.1.20.0000.00817.54
8.1.10.0000.00817.57
8.1.00.0080.00017.61
8.0.300.0030.00618.77
8.0.290.0030.00617.16
8.0.280.0000.00718.47
8.0.270.0000.00817.16
8.0.260.0070.00016.86
8.0.250.0000.00716.91
8.0.240.0000.00716.98
8.0.230.0050.00316.97
8.0.220.0030.00316.84
8.0.210.0070.00016.95
8.0.200.0030.00316.97
8.0.190.0040.00417.02
8.0.180.0000.00716.96
8.0.170.0050.00316.95
8.0.160.0040.00416.91
8.0.150.0040.00416.88
8.0.140.0030.00516.80
8.0.130.0000.00613.33
8.0.120.0000.00716.86
8.0.110.0000.00716.92
8.0.100.0020.00517.04
8.0.90.0070.00016.94
8.0.80.0100.01016.98
8.0.70.0080.00016.85
8.0.60.0040.00416.82
8.0.50.0030.00616.84
8.0.30.0080.01216.97
8.0.20.0080.01317.40
8.0.10.0040.00417.02
8.0.00.0100.01116.88
7.4.330.0000.00515.02
7.4.320.0000.00616.59
7.4.300.0030.00316.55
7.4.290.0030.00316.50
7.4.280.0070.00016.54
7.4.270.0030.00316.53
7.4.260.0040.00416.55
7.4.250.0000.00716.54
7.4.240.0010.00616.60
7.4.230.0070.00016.38
7.4.220.0100.00516.53
7.4.210.0060.01016.63
7.4.200.0030.00316.61
7.4.190.0000.00716.61
7.4.160.0030.01516.55
7.4.150.0090.01217.40
7.4.140.0090.01317.86
7.4.130.0060.01416.59
7.4.120.0150.00616.48
7.4.110.0170.00016.54
7.4.100.0170.00816.45
7.4.90.0180.00616.54
7.4.80.0080.00816.54
7.4.70.0030.01316.54
7.4.60.0090.00916.43
7.4.50.0040.00416.21
7.4.40.0090.00622.77
7.4.30.0100.01116.38
7.4.00.0120.00614.93
7.3.330.0030.00313.20
7.3.320.0050.00013.29
7.3.310.0040.00416.50
7.3.300.0030.00316.34
7.3.290.0080.00816.29
7.3.280.0060.01216.36
7.3.270.0100.00717.40
7.3.260.0150.00316.66
7.3.250.0110.00816.42
7.3.240.0100.00716.48
7.3.230.0100.00616.40
7.3.210.0120.00616.32
7.3.200.0060.01219.39
7.3.190.0160.00616.64
7.3.180.0060.00916.46
7.3.170.0060.00916.59
7.3.160.0160.00016.34
7.3.120.0090.00614.95
7.3.00.0100.00316.24
7.2.330.0060.01216.71
7.2.320.0150.00416.94
7.2.310.0100.01316.81
7.2.300.0130.01016.69
7.2.290.0060.01516.88
7.2.130.0030.01316.70
7.2.120.0070.00716.42
7.2.110.0030.01016.62
7.2.100.0140.00416.37
7.2.90.0100.00316.45
7.2.80.0120.00316.99
7.2.70.0160.00017.10
7.2.60.0120.00616.72
7.2.50.0130.00316.48
7.2.40.0120.00316.86
7.2.30.0070.01116.91
7.2.20.0060.01016.52
7.2.10.0090.00616.88
7.2.00.0070.01016.93
7.1.250.0090.01015.66
7.1.240.0080.00315.61
7.1.230.0030.01015.78
7.1.220.0060.00915.61
7.1.210.0090.00315.57
7.1.200.0100.00615.62
7.1.190.0090.00315.52
7.1.180.0110.00415.54
7.1.170.0080.00415.61
7.1.160.0110.00415.51
7.1.150.0100.00315.82
7.1.140.0070.00715.64
7.1.130.0120.00615.65
7.1.120.0030.01015.71
7.1.110.0150.00315.59
7.1.100.0100.00715.75
7.1.90.0030.01015.30
7.1.80.0090.00915.49
7.1.70.0070.00416.45
7.1.60.0090.01017.40
7.1.50.0040.01816.23
7.1.40.0090.00615.45
7.1.30.0040.00815.50
7.1.20.0060.00615.65
7.1.10.0110.00415.70
7.1.00.0070.04219.15
7.0.330.0080.01215.05
7.0.320.0120.00615.29
7.0.310.0000.01615.11
7.0.300.0110.00414.94
7.0.290.0100.00715.23
7.0.280.0160.00314.95
7.0.270.0130.00615.36
7.0.260.0030.00915.36
7.0.250.0100.00315.22
7.0.240.0090.00315.03
7.0.230.0060.00614.85
7.0.220.0060.00615.20
7.0.210.0100.00315.21
7.0.200.0070.00516.03
7.0.190.0090.00615.06
7.0.180.0070.00715.45
7.0.170.0070.01015.05
7.0.160.0000.01415.35
7.0.150.0040.01115.18
7.0.140.0090.03718.50
7.0.130.0070.00715.34
7.0.120.0080.00315.28
7.0.110.0080.04618.44
7.0.100.0070.04118.44
7.0.90.0110.03718.46
7.0.80.0090.03618.39
7.0.70.0100.04218.20
7.0.60.0100.02518.50
7.0.50.0080.04018.43
7.0.40.0040.02416.52
7.0.30.0030.02816.49
7.0.20.0030.02916.47
7.0.10.0030.04416.50
7.0.00.0020.02216.51
5.6.380.0000.01514.28
5.6.370.0080.00414.32
5.6.360.0060.01014.68
5.6.350.0040.00814.07
5.6.340.0000.01214.53
5.6.330.0030.00714.04
5.6.320.0130.00014.08
5.6.310.0040.01114.53
5.6.300.0060.00814.11
5.6.290.0040.01114.12
5.6.280.0100.03517.44
5.6.270.0060.00814.60
5.6.260.0040.04417.62
5.6.250.0100.03717.40
5.6.240.0100.03517.56
5.6.230.0080.04117.72
5.6.220.0060.04017.46
5.6.210.0000.03617.45
5.6.200.0080.04017.35
5.6.190.0040.04417.51
5.6.180.0030.04317.41
5.6.170.0050.02517.31
5.6.160.0050.02917.29
5.6.150.0050.04017.29
5.6.140.0050.04317.33
5.6.130.0050.04417.37
5.6.120.0050.03017.56
5.6.110.0060.02217.43
5.6.100.0020.04317.34
5.6.90.0060.02917.34
5.6.80.0090.03817.13
5.6.70.0020.02516.98
5.6.60.0050.04317.13
5.6.50.0060.04216.92
5.6.40.0050.04216.94
5.6.30.0050.04217.06
5.6.20.0120.03517.19
5.6.10.0060.04017.11
5.6.00.0040.02917.03
5.5.380.0010.02614.26
5.5.370.0070.03814.42
5.5.360.0080.03814.31
5.5.350.0000.03014.23
5.5.340.0020.04414.75
5.5.330.0020.03814.50
5.5.320.0060.03514.38
5.5.310.0030.04014.38
5.5.300.0040.04214.53
5.5.290.0040.04014.63
5.5.280.0030.02314.42
5.5.270.0040.04114.52
5.5.260.0020.02214.53
5.5.250.0000.03914.30
5.5.240.0060.01714.07
5.5.230.0020.02214.32
5.5.220.0020.04214.23
5.5.210.0030.03814.20
5.5.200.0040.02514.19
5.5.190.0050.03714.17
5.5.180.0020.02714.09
5.5.170.0060.00310.90
5.5.160.0050.03914.21
5.5.150.0030.03014.19
5.5.140.0070.03714.05
5.5.130.0030.02814.04
5.5.120.0000.04114.00
5.5.110.0080.02214.25
5.5.100.0090.03314.14
5.5.90.0070.03814.06
5.5.80.0040.04114.08
5.5.70.0050.04014.19
5.5.60.0070.04014.12
5.5.50.0040.02414.21
5.5.40.0030.02414.24
5.5.30.0060.03214.18
5.5.20.0060.02814.32
5.5.10.0080.03514.19
5.5.00.0050.02114.17
5.4.450.0010.04515.10
5.4.440.0060.02115.38
5.4.430.0070.03715.39
5.4.420.0020.03915.17
5.4.410.0030.03115.03
5.4.400.0060.03414.92
5.4.390.0030.03314.98
5.4.380.0020.04014.96
5.4.370.0090.02214.93
5.4.360.0000.04214.95
5.4.350.0060.03614.93
5.4.340.0040.03614.95
5.4.330.0030.00910.90
5.4.320.0020.04014.99
5.4.310.0050.04515.05
5.4.300.0010.02714.95
5.4.290.0020.03515.16
5.4.280.0060.03814.91
5.4.270.0050.02015.05
5.4.260.0020.04115.05
5.4.250.0040.02114.98
5.4.240.0040.02015.03
5.4.230.0020.04215.15
5.4.220.0060.04015.06
5.4.210.0070.03215.03
5.4.200.0030.04114.97
5.4.190.0050.03815.07
5.4.180.0060.03815.09
5.4.170.0060.04015.16
5.4.160.0070.03814.98
5.4.150.0050.03414.95
5.4.140.0000.03713.66
5.4.130.0040.03713.54
5.4.120.0040.03113.62
5.4.110.0030.04113.65
5.4.100.0050.03313.71
5.4.90.0050.04013.78
5.4.80.0050.03613.52
5.4.70.0030.03813.77
5.4.60.0060.03613.70
5.4.50.0050.03813.64
5.4.40.0040.03813.71
5.4.30.0060.03413.63
5.4.20.0060.03813.64
5.4.10.0050.04013.57
5.4.00.0070.03313.28
5.3.290.0030.04112.71
5.3.280.0030.04012.73
5.3.270.0050.02912.74
5.3.260.0070.03312.66
5.3.250.0050.03512.73
5.3.240.0000.04912.69
5.3.230.0010.03812.76
5.3.220.0060.03612.74
5.3.210.0020.02812.67
5.3.200.0020.04312.69
5.3.190.0040.03012.71
5.3.180.0050.03512.77
5.3.170.0050.03812.78
5.3.160.0030.03512.78
5.3.150.0070.03712.67
5.3.140.0080.03812.70
5.3.130.0040.04012.71
5.3.120.0060.03912.79
5.3.110.0020.04512.68
5.3.100.0030.04112.38
5.3.90.0000.03612.44
5.3.80.0030.04012.41
5.3.70.0050.03712.44
5.3.60.0020.03612.47
5.3.50.0040.03912.45
5.3.40.0080.02212.42
5.3.30.0040.04012.35
5.3.20.0070.02012.27
5.3.10.0070.03412.26
5.3.00.0020.04112.19
5.2.170.0050.03711.04
5.2.160.0080.02511.05
5.2.150.0030.03510.98
5.2.140.0040.03411.01
5.2.130.0040.03210.98
5.2.120.0020.03610.91
5.2.110.0050.01911.02
5.2.100.0030.03010.98
5.2.90.0070.03210.98
5.2.80.0040.03011.02
5.2.70.0000.02610.97
5.2.60.0030.02710.96
5.2.50.0030.03310.93
5.2.40.0050.02510.93
5.2.30.0050.02710.91
5.2.20.0000.03410.91
5.2.10.0030.01810.93
5.2.00.0030.03010.89
5.1.60.0040.02010.37
5.1.50.0060.02310.54
5.1.40.0010.02810.41
5.1.30.0090.02210.63
5.1.20.0000.02110.64
5.1.10.0020.03010.45
5.1.00.0030.03110.51
5.0.50.0030.0229.82
5.0.40.0020.0129.76
5.0.30.0000.0329.54
5.0.20.0020.0249.65
5.0.10.0040.0179.59
5.0.00.0000.0339.54
4.4.90.0030.0109.14
4.4.80.0030.0169.14
4.4.70.0040.0169.14
4.4.60.0040.0189.14
4.4.50.0030.0179.14
4.4.40.0030.0279.14
4.4.30.0020.0139.14
4.4.20.0060.0179.14
4.4.10.0020.0189.14
4.4.00.0050.0229.14
4.3.110.0000.0129.14
4.3.100.0020.0209.14
4.3.90.0020.0189.14
4.3.80.0030.0239.14
4.3.70.0010.0189.14
4.3.60.0050.0119.14
4.3.50.0020.0129.14
4.3.40.0010.0269.14
4.3.30.0000.0139.14
4.3.20.0020.0209.14
4.3.10.0000.0229.14
4.3.00.0000.0229.14

preferences:
54.81 ms | 401 KiB | 5 Q