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] == "(") 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] == ")")) { // go back to the first non-whitespace $whitespaces = ""; if ($parenthesis_count == -1) { $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?")":","); // 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.70.0100.01316.63
8.3.60.0040.01118.43
8.3.50.0120.00722.07
8.3.40.0140.00718.89
8.3.30.0110.00719.04
8.3.20.0070.00720.29
8.3.10.0030.01023.67
8.3.00.0060.00320.57
8.2.180.0160.00016.63
8.2.170.0110.01122.96
8.2.160.0150.00322.13
8.2.150.0120.00624.18
8.2.140.0160.00324.66
8.2.130.0000.01426.16
8.2.120.0040.00419.36
8.2.110.0000.00920.35
8.2.100.0100.00317.84
8.2.90.0050.00319.35
8.2.80.0060.00317.97
8.2.70.0070.00317.63
8.2.60.0030.00617.92
8.2.50.0000.00818.07
8.2.40.0040.00418.16
8.2.30.0000.00818.04
8.2.20.0030.00617.74
8.2.10.0030.00617.80
8.2.00.0030.00617.77
8.1.280.0100.00725.92
8.1.270.0030.00524.02
8.1.260.0160.00326.35
8.1.250.0050.00328.09
8.1.240.0070.01122.17
8.1.230.0070.00319.04
8.1.220.0000.00817.77
8.1.210.0090.00018.77
8.1.200.0030.00617.47
8.1.190.0030.00517.28
8.1.180.0000.00818.10
8.1.170.0030.00618.61
8.1.160.0070.00022.03
8.1.150.0030.00518.69
8.1.140.0040.00417.51
8.1.130.0000.00717.92
8.1.120.0080.00017.40
8.1.110.0060.00317.49
8.1.100.0070.00017.39
8.1.90.0070.00317.53
8.1.80.0000.00717.55
8.1.70.0000.00817.53
8.1.60.0080.00017.65
8.1.50.0050.00217.40
8.1.40.0080.00017.59
8.1.30.0060.00317.60
8.1.20.0000.00717.61
8.1.10.0040.00417.63
8.1.00.0050.00317.43
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0030.00318.56
8.0.270.0000.00717.23
8.0.260.0040.00416.87
8.0.250.0060.00017.04
8.0.240.0000.00816.99
8.0.230.0040.00416.90
8.0.220.0030.00516.82
8.0.210.0040.00416.84
8.0.200.0030.00317.00
8.0.190.0070.00017.01
8.0.180.0030.00616.99
8.0.170.0080.00016.88
8.0.160.0000.00816.82
8.0.150.0030.00616.90
8.0.140.0000.00816.81
8.0.130.0060.00013.34
8.0.120.0060.00316.87
8.0.110.0030.00516.88
8.0.100.0030.00616.84
8.0.90.0040.00416.80
8.0.80.0070.01016.95
8.0.70.0070.00016.84
8.0.60.0040.00416.95
8.0.50.0070.00016.95
8.0.30.0120.00916.89
8.0.20.0080.01117.42
8.0.10.0040.00416.95
8.0.00.0050.01516.81
7.4.330.0000.00615.09
7.4.320.0000.00716.57
7.4.300.0000.00616.57
7.4.290.0030.00316.70
7.4.280.0040.00416.66
7.4.270.0000.00716.63
7.4.260.0070.00016.69
7.4.250.0070.00016.59
7.4.240.0040.00416.68
7.4.230.0030.00516.47
7.4.220.0100.00716.50
7.4.210.0070.00916.74
7.4.200.0030.00316.69
7.4.190.0030.00316.62
7.4.160.0100.00716.56
7.4.150.0170.00717.40
7.4.140.0110.00817.86
7.4.130.0100.01016.66
7.4.120.0090.00816.48
7.4.110.0180.00016.64
7.4.100.0140.00316.46
7.4.90.0130.01016.69
7.4.80.0170.00716.70
7.4.70.0110.00616.75
7.4.60.0030.01316.43
7.4.50.0020.00216.52
7.4.40.0060.00622.77
7.4.30.0030.01316.42
7.4.00.0030.00715.02
7.3.330.0050.00013.13
7.3.320.0000.00613.11
7.3.310.0070.00016.35
7.3.300.0000.00716.38
7.3.290.0110.00316.33
7.3.280.0100.00816.41
7.3.270.0130.00517.40
7.3.260.0130.01016.40
7.3.250.0140.00316.52
7.3.240.0030.01316.59
7.3.230.0060.01016.48
7.3.210.0130.00316.61
7.3.200.0090.01219.39
7.3.190.0000.01716.54
7.3.180.0120.00316.49
7.3.170.0060.01016.39
7.3.160.0060.01316.39
7.3.120.0100.00314.98
7.2.330.0090.00916.60
7.2.320.0090.00916.47
7.2.310.0030.01516.79
7.2.300.0100.00716.78
7.2.290.0090.00916.65
7.2.00.0060.00619.46
7.1.100.0000.01318.17
7.1.70.0000.00917.09
7.1.60.0100.01619.32
7.1.50.0110.00617.03
7.1.00.0070.07022.36
7.0.200.0100.00716.81
7.0.140.0000.07722.21
7.0.60.0100.04019.83
7.0.50.0030.08717.78
7.0.40.0000.06020.23
7.0.30.0200.08720.11
7.0.20.0230.04020.12
7.0.10.0270.07020.09
7.0.00.0070.06020.11
5.6.280.0030.07021.11
5.6.210.0070.03720.70
5.6.200.0200.06718.19
5.6.190.0070.04320.67
5.6.180.0100.05020.60
5.6.170.0330.03720.37
5.6.160.0030.07720.41
5.6.150.0070.08718.21
5.6.140.0100.04318.07
5.6.130.0030.09018.14
5.6.120.0070.05721.01
5.6.110.0270.06021.01
5.6.100.0100.04321.05
5.6.90.0130.07020.91
5.6.80.0100.04320.56
5.6.70.0270.06320.46
5.5.350.0300.07020.46
5.5.340.0030.09018.02
5.5.330.0130.08320.42
5.5.320.0000.09320.13
5.5.310.0270.04720.33
5.5.300.0100.07717.98
5.5.290.0070.08018.01
5.5.280.0100.04320.83
5.5.270.0030.04720.90
5.5.260.0100.07020.90
5.5.250.0200.06720.72
5.5.240.0130.07320.16
5.4.450.0600.05319.13
5.4.440.1030.06719.56
5.4.430.1030.05719.22
5.4.420.0470.06719.51
5.4.410.0200.05319.11
5.4.400.0130.07718.55
5.4.390.0370.05718.69
5.4.380.0270.05018.69
5.4.370.0100.05318.50
5.4.360.0170.04318.52
5.4.350.0050.03912.04
5.4.340.0110.04312.03
5.4.320.0080.03712.52
5.4.310.0080.04112.52
5.4.300.0030.04312.52
5.4.290.0060.04212.51
5.4.280.0070.04012.41
5.4.270.0050.04212.41
5.4.260.0090.04512.41
5.4.250.0060.05112.41
5.4.240.0100.03912.41
5.4.230.0020.04012.41
5.4.220.0070.03512.41
5.4.210.0030.03812.41
5.4.200.0080.04212.40
5.4.190.0080.04512.40
5.4.180.0050.03612.40
5.4.170.0170.04112.40
5.4.160.0130.04612.39
5.4.150.0200.06912.39
5.4.140.0160.04212.07
5.4.130.0130.04512.05
5.4.120.0130.04412.01
5.4.110.0150.04212.01
5.4.100.0140.04412.01
5.4.90.0230.06512.01
5.4.80.0180.03912.01
5.4.70.0170.04012.00
5.4.60.0140.04212.00
5.4.50.0180.04012.00
5.4.40.0160.04212.00
5.4.30.0070.05011.99
5.4.20.0140.04312.00
5.4.10.0430.07812.00
5.4.00.0170.04311.48
5.3.290.0050.03912.80
5.3.280.0070.04512.71
5.3.270.0170.04612.73
5.3.260.0170.04312.72
5.3.250.0150.04512.72
5.3.240.0120.04812.71
5.3.230.0190.04512.71
5.3.220.0290.06412.68
5.3.210.0140.04812.68
5.3.200.0170.04312.68
5.3.190.0160.04712.68
5.3.180.0210.03912.67
5.3.170.0150.04612.68
5.3.160.0170.04312.67
5.3.150.0230.06712.67
5.3.140.0130.04812.67
5.3.130.0150.04912.66
5.3.120.0290.06212.66
5.3.110.0150.04612.66
5.3.100.0190.04112.14
5.3.90.0140.04412.13
5.3.80.0160.04412.12
5.3.70.0220.04012.11
5.3.60.0400.08412.10
5.3.50.0190.04612.05
5.3.40.0140.04612.05
5.3.30.0120.04512.02
5.3.20.0300.08811.79
5.3.10.0150.04111.75
5.3.00.0190.03811.74
5.2.170.0140.0359.25
5.2.160.0120.0359.25
5.2.150.0140.0339.25
5.2.140.0130.0369.25
5.2.130.0130.0349.21
5.2.120.0100.0379.20
5.2.110.0210.0589.21
5.2.100.0130.0349.21
5.2.90.0130.0369.20
5.2.80.0100.0379.20
5.2.70.0120.0359.20
5.2.60.0140.0339.16
5.2.50.0190.0289.12
5.2.40.0130.0359.10
5.2.30.0140.0329.07
5.2.20.0110.0369.07
5.2.10.0130.0338.99
5.2.00.0160.0298.85
5.1.60.0150.0278.14
5.1.50.0190.0528.14
5.1.40.0130.0288.12
5.1.30.0130.0298.47
5.1.20.0090.0348.50
5.1.10.0160.0268.21
5.1.00.0140.0278.21
5.0.50.0150.0496.71
5.0.40.0040.0286.57
5.0.30.0080.0386.39
5.0.20.0140.0226.37
5.0.10.0090.0236.35
5.0.00.0040.0416.34
4.4.90.0060.0194.78
4.4.80.0040.0214.75
4.4.70.0050.0214.76
4.4.60.0090.0164.76
4.4.50.0100.0164.77
4.4.40.0040.0324.73
4.4.30.0070.0194.76
4.4.20.0070.0184.85
4.4.10.0080.0174.85
4.4.00.0060.0304.76
4.3.110.0050.0204.67
4.3.100.0050.0194.66
4.3.90.0060.0184.65
4.3.80.0100.0254.65
4.3.70.0070.0184.65
4.3.60.0100.0154.65
4.3.50.0110.0154.64
4.3.40.0090.0254.61
4.3.30.0050.0193.41
4.3.20.0070.0163.41
4.3.10.0040.0193.36
4.3.00.0170.0277.00

preferences:
60.61 ms | 401 KiB | 5 Q