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.0060.01518.43
8.3.50.0110.00822.00
8.3.40.0090.00618.87
8.3.30.0070.00719.12
8.3.20.0040.00420.34
8.3.10.0000.00821.92
8.3.00.0000.00822.27
8.2.180.0140.00316.88
8.2.170.0090.00622.96
8.2.160.0070.00720.83
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0000.00726.16
8.2.120.0080.00017.75
8.2.110.0060.00322.16
8.2.100.0130.00017.97
8.2.90.0060.00317.63
8.2.80.0080.00017.97
8.2.70.0050.00318.03
8.2.60.0070.00017.93
8.2.50.0000.00718.10
8.2.40.0000.00820.53
8.2.30.0080.00418.16
8.2.20.0000.00817.76
8.2.10.0000.00817.70
8.2.00.0000.00817.71
8.1.280.0140.00025.92
8.1.270.0060.00322.06
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0040.00420.83
8.1.230.0040.00719.16
8.1.220.0050.00317.76
8.1.210.0000.00818.77
8.1.200.0030.00717.23
8.1.190.0040.00417.23
8.1.180.0030.00718.10
8.1.170.0080.00018.57
8.1.160.0040.00421.95
8.1.150.0000.00718.68
8.1.140.0080.00017.46
8.1.130.0080.00017.73
8.1.120.0070.00017.45
8.1.110.0120.00017.35
8.1.100.0070.00017.36
8.1.90.0000.00817.45
8.1.80.0000.00717.43
8.1.70.0070.00017.42
8.1.60.0030.00617.50
8.1.50.0000.00717.42
8.1.40.0000.00817.54
8.1.30.0040.00417.65
8.1.20.0000.00817.74
8.1.10.0040.00417.60
8.1.00.0050.00217.61
8.0.300.0070.00019.73
8.0.290.0060.00316.75
8.0.280.0000.00818.35
8.0.270.0050.00217.32
8.0.260.0000.00618.52
8.0.250.0000.01016.89
8.0.240.0000.00717.02
8.0.230.0050.00216.97
8.0.220.0070.00016.85
8.0.210.0000.00716.82
8.0.200.0070.00017.01
8.0.190.0030.00616.96
8.0.180.0070.00016.98
8.0.170.0080.00016.99
8.0.160.0050.00216.74
8.0.150.0030.00516.97
8.0.140.0030.00316.88
8.0.130.0060.00013.35
8.0.120.0030.00516.79
8.0.110.0030.00516.96
8.0.100.0040.00416.80
8.0.90.0000.00816.83
8.0.80.0090.00616.92
8.0.70.0070.00016.80
8.0.60.0000.00716.99
8.0.50.0040.00416.80
8.0.30.0170.01017.19
8.0.20.0090.01017.40
8.0.10.0070.00017.08
8.0.00.0060.01316.72
7.4.330.0030.00315.14
7.4.320.0030.00316.68
7.4.300.0040.00416.54
7.4.290.0050.00216.61
7.4.280.0000.00816.53
7.4.270.0050.00316.69
7.4.260.0000.00716.38
7.4.250.0080.00016.43
7.4.240.0040.00316.58
7.4.230.0030.00316.57
7.4.220.0100.01016.54
7.4.210.0070.00916.60
7.4.200.0000.00716.66
7.4.190.0040.00416.71
7.4.160.0040.01216.56
7.4.150.0160.01017.40
7.4.140.0110.00617.86
7.4.130.0050.01316.62
7.4.120.0040.01216.63
7.4.110.0180.00316.38
7.4.100.0030.01416.31
7.4.90.0100.01016.51
7.4.80.0090.01219.39
7.4.70.0100.01016.64
7.4.60.0080.00816.46
7.4.50.0030.00316.45
7.4.40.0060.00922.77
7.4.30.0080.00916.59
7.4.00.0070.01014.87
7.3.330.0050.00013.22
7.3.320.0060.00013.34
7.3.310.0000.00716.29
7.3.300.0000.00716.37
7.3.290.0060.01016.27
7.3.280.0090.01016.34
7.3.270.0130.00317.40
7.3.260.0100.00716.37
7.3.250.0100.00716.51
7.3.240.0030.01316.49
7.3.230.0050.01116.54
7.3.210.0060.01016.65
7.3.200.0120.00619.39
7.3.190.0030.01316.27
7.3.180.0070.01116.51
7.3.170.0060.01316.30
7.3.160.0140.00516.41
7.3.120.0030.01314.84
7.3.110.0040.01214.87
7.3.100.0070.00314.74
7.3.90.0030.00814.96
7.3.80.0060.00614.95
7.3.70.0070.00714.95
7.3.60.0030.01014.78
7.3.50.0030.00714.55
7.3.40.0080.00514.79
7.3.30.0060.00514.82
7.3.20.0030.00916.78
7.3.10.0000.01016.65
7.3.00.0030.01016.75
7.2.330.0120.00616.81
7.2.320.0160.00716.84
7.2.310.0060.01216.39
7.2.300.0060.00916.79
7.2.290.0120.00616.75
7.2.250.0100.00615.32
7.2.240.0030.01714.86
7.2.230.0000.01615.27
7.2.220.0100.00715.11
7.2.210.0120.00015.11
7.2.200.0060.00914.89
7.2.190.0120.00014.78
7.2.180.0030.01415.08
7.2.170.0070.00715.18
7.2.00.0030.01019.61
7.1.330.0070.00715.79
7.1.320.0080.01115.71
7.1.310.0030.01015.70
7.1.300.0060.00315.92
7.1.290.0070.00715.69
7.1.280.0000.01615.77
7.1.270.0070.00315.95
7.1.260.0070.00715.64
7.1.200.0030.01015.56
7.1.100.0190.01117.91
7.1.70.0000.00816.85
7.1.60.0040.00817.30
7.1.50.0040.01916.69
7.1.00.0000.08022.45
7.0.200.0030.01316.69
7.0.140.0030.06721.96
7.0.70.0300.07719.92
7.0.60.0800.05020.09
7.0.50.0870.06020.19
7.0.40.0070.08720.13
7.0.30.0100.05320.15
7.0.20.0130.07720.14
7.0.10.0000.08320.10
7.0.00.0030.05019.99
5.6.220.0170.05020.57
5.6.210.0070.09020.78
5.6.200.0030.07721.10
5.6.190.0130.08721.05
5.6.180.0070.08320.97
5.6.170.0030.08721.03
5.6.160.0100.08320.96
5.6.150.0030.08321.12
5.6.140.0070.08321.18
5.6.130.0030.08321.04
5.6.120.0200.07021.05
5.6.110.0000.05721.11
5.6.100.0070.08721.10
5.6.90.0100.08021.07
5.6.80.0000.06020.56
5.6.70.0070.07720.39
5.6.60.0100.07020.40
5.6.50.0100.08320.35
5.6.40.0070.05320.30
5.6.30.0030.08320.35
5.6.20.0130.07720.39
5.6.10.0070.08320.38
5.6.00.0100.08020.24
5.5.360.0100.08020.43
5.5.350.0070.07720.43
5.5.340.0130.08020.85
5.5.330.0030.08320.91
5.5.320.0030.05320.89
5.5.310.0070.08720.91
5.5.300.0130.08320.74
5.5.290.0100.08320.82
5.5.280.0070.04320.65
5.5.270.0030.08320.80
5.5.260.0130.07320.91
5.5.250.0030.07020.75
5.5.240.0070.07720.29
5.5.230.0030.08320.31
5.5.220.0100.07020.27
5.5.210.0030.06020.18
5.5.200.0070.08320.29
5.5.190.0130.08020.29
5.5.180.0100.07720.30
5.5.160.0030.08320.16
5.5.150.0070.03720.00
5.5.140.0170.06720.19
5.5.130.0100.06320.23
5.5.120.0170.05720.25
5.5.110.0100.05720.13
5.5.100.0000.05320.09
5.5.90.0070.05720.17
5.5.80.0030.08720.09
5.5.70.0170.07720.01
5.5.60.0030.05320.07
5.5.50.0000.05020.17
5.5.40.0070.03720.06
5.5.30.0070.05320.05
5.5.20.0130.08320.15
5.5.10.0100.07720.09
5.5.00.0100.07719.96
5.4.450.0100.07719.36
5.4.440.0100.07719.35
5.4.430.0100.05719.40
5.4.420.0100.08319.22
5.4.410.0030.08719.24
5.4.400.0100.07319.07
5.4.390.0070.04718.78
5.4.380.0000.06718.96
5.4.370.0130.07018.93
5.4.360.0100.07318.90
5.4.350.0030.08018.96
5.4.340.0070.06319.14
5.4.320.0070.08018.93
5.4.310.0030.03719.14
5.4.300.0070.07719.02
5.4.290.0170.05318.96
5.4.280.0100.06019.12
5.4.270.0070.07719.03
5.4.260.0030.05318.94
5.4.250.0000.08018.75
5.4.240.0070.07318.97
5.4.230.0030.07318.95
5.4.220.0100.07319.02
5.4.210.0100.08019.11
5.4.200.0070.03718.81
5.4.190.0100.07319.02
5.4.180.0070.07719.04
5.4.170.0070.07318.89
5.4.160.0070.05319.00
5.4.150.0100.05019.07
5.4.140.0030.07716.09
5.4.130.0070.07316.29
5.4.120.0100.07016.28
5.4.110.0070.07016.30
5.4.100.0030.05316.21
5.4.90.0070.04316.23
5.4.80.0100.04716.36
5.4.70.0070.06316.39
5.4.60.0170.06716.30
5.4.50.0100.07716.18
5.4.40.0070.03716.43
5.4.30.0100.04716.39
5.4.20.0030.07716.25
5.4.10.0100.05716.29
5.4.00.0100.06015.82
5.3.290.0030.07714.68
5.3.280.0100.06714.62
5.3.270.0030.08014.47
5.3.260.0030.08014.45
5.3.250.0170.07014.49
5.3.240.0000.06014.60
5.3.230.0030.05714.58
5.3.220.0070.04714.57
5.3.210.0100.06014.59
5.3.200.0030.06314.57
5.3.190.0070.07314.43
5.3.180.0130.07014.46
5.3.170.0030.05314.55
5.3.160.0030.05714.45
5.3.150.0000.05714.54
5.3.140.0070.05014.57
5.3.130.0030.04714.58
5.3.120.0030.04314.43
5.3.110.0030.07014.40
5.3.100.0030.04013.90
5.3.90.0000.04013.95
5.3.80.0100.05014.03
5.3.70.0070.04313.80
5.3.60.0070.06014.04
5.3.50.0070.04713.96
5.3.40.0070.03313.88
5.3.30.0200.06013.80
5.3.20.0030.07713.67
5.3.10.0070.08013.55
5.3.00.0030.07713.52
5.2.170.0070.06312.25
5.2.160.0070.03312.25
5.2.150.0070.04712.25
5.2.140.0000.05312.25
5.2.130.0070.06712.25
5.2.120.0030.06312.25
5.2.110.0070.05712.25
5.2.100.0100.03012.25
5.2.90.0030.06312.25
5.2.80.0070.04012.25
5.2.70.0000.05012.25
5.2.60.0100.05012.25
5.2.50.0070.06312.25
5.2.40.0070.05312.25
5.2.30.0030.05012.25
5.2.20.0070.06012.25
5.2.10.0030.05312.25
5.2.00.0070.03312.25
5.1.60.0000.02712.25
5.1.50.0030.03012.25
5.1.40.0070.04312.25
5.1.30.0030.05712.25
5.1.20.0000.06012.25
5.1.10.0070.05712.25
5.1.00.0030.04712.25
5.0.50.0030.04312.25
5.0.40.0000.04712.25
5.0.30.0100.06012.25
5.0.20.0030.04712.25
5.0.10.0070.03712.25
5.0.00.0000.04712.25
4.4.90.0070.03012.25
4.4.80.0030.02312.25
4.4.70.0030.03712.25
4.4.60.0130.02012.25
4.4.50.0100.02712.25
4.4.40.0070.04012.25
4.4.30.0000.03012.25
4.4.20.0030.03712.25
4.4.10.0000.03712.25
4.4.00.0000.03712.25
4.3.110.0030.03312.25
4.3.100.0000.04012.25
4.3.90.0070.03312.25
4.3.80.0030.05712.25
4.3.70.0070.03312.25
4.3.60.0030.03012.25
4.3.50.0070.03012.25
4.3.40.0030.04712.25
4.3.30.0030.03312.25
4.3.20.0000.04012.25
4.3.10.0070.02312.25
4.3.00.0000.03712.25

preferences:
63.44 ms | 404 KiB | 6 Q