3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * check matching od braces * * @param string $src target string to check * @return bool */ function brace_check($src) { $open_braces = str_split("({["); $close_braces = str_split(")}]"); $braces = array_merge($open_braces, $close_braces); $tokens = token_get_all($src); var_dump($tokens); //$tokens = array_filter($tokens,function($item){ return is_string($item); }); var_dump($tokens); $tokens = array_walk_recursive($tokens,function(&$item){ if (is_int($item)) $item = token_name($item); }); $open_brace_stack = array(); foreach($tokens as $key => $t){ if (in_array($t,$open_braces)){ array_push( $open_brace_stack, $t); } elseif (in_array($t,$close_braces)){ if ( empty($open_brace_stack) ){ return false; } $open_top = array_pop($open_brace_stack); $idx_open = array_search($open_top, $open_braces); $idx_close = array_search($t, $close_braces); if ( $idx_open !== $idx_close ){ return false; } } echo "token:$t" . PHP_EOL; echo "open_brace_stack:" . print_r($open_brace_stack,true) . PHP_EOL; } return true; } //========================= // test code $html_case = <<<HTML <?php ?> <html> ... <ul> <li>1)...</li> <li>2)...</li> </ul> ... <?php ... ?> ... </html> HTML; $expressions = array(")(){}","[]({})","([])","{()[]}","([)]",$html_case); //var_dump(array_map('brace_check', $expressions)); echo brace_check("([)]");

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.0040.01118.45
8.3.60.0070.01416.63
8.3.50.0140.00721.09
8.3.40.0070.01118.92
8.3.30.0030.01019.04
8.3.20.0080.00020.33
8.3.10.0000.00823.66
8.3.00.0000.00817.63
8.2.190.0090.00616.75
8.2.180.0130.00916.50
8.2.170.0030.01022.96
8.2.160.0110.00320.35
8.2.150.0030.01024.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0080.00021.05
8.2.110.0100.00022.15
8.2.100.0090.00317.97
8.2.90.0050.00319.21
8.2.80.0000.00817.97
8.2.70.0030.00517.38
8.2.60.0050.00317.80
8.2.50.0050.00318.07
8.2.40.0000.00819.95
8.2.30.0050.00318.13
8.2.20.0080.00017.61
8.2.10.0040.00418.18
8.2.00.0000.00818.03
8.1.280.0030.01025.92
8.1.270.0120.00620.33
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00423.86
8.1.230.0110.00022.65
8.1.220.0000.00917.78
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0000.00817.35
8.1.180.0000.00718.10
8.1.170.0030.00620.43
8.1.160.0040.00422.09
8.1.150.0050.00318.82
8.1.140.0000.00717.42
8.1.130.0030.00617.77
8.1.120.0030.00517.52
8.1.110.0050.00217.47
8.1.100.0070.00017.51
8.1.90.0050.00217.35
8.1.80.0040.00417.39
8.1.70.0040.00417.40
8.1.60.0030.00617.68
8.1.50.0040.00417.44
8.1.40.0000.00817.50
8.1.30.0060.00317.71
8.1.20.0090.00017.57
8.1.10.0040.00417.51
8.1.00.0030.00617.50
8.0.300.0000.00818.77
8.0.290.0040.00416.63
8.0.280.0050.00218.44
8.0.270.0070.00017.26
8.0.260.0030.00317.33
8.0.250.0040.00417.01
8.0.240.0000.00717.07
8.0.230.0070.00016.94
8.0.220.0000.00716.98
8.0.210.0070.00016.90
8.0.200.0000.00617.01
8.0.190.0060.00317.04
8.0.180.0040.00416.96
8.0.170.0040.00416.96
8.0.160.0030.00616.93
8.0.150.0040.00417.00
8.0.140.0000.00716.97
8.0.130.0030.00313.42
8.0.120.0000.00817.01
8.0.110.0040.00416.95
8.0.100.0050.00316.97
8.0.90.0000.00816.89
8.0.80.0110.00816.95
8.0.70.0050.00316.93
8.0.60.0030.00516.95
8.0.50.0000.00816.88
8.0.30.0220.00317.21
8.0.20.0070.01217.42
8.0.10.0000.00817.06
8.0.00.0090.00916.82
7.4.330.0030.00315.15
7.4.320.0030.00316.61
7.4.300.0000.00616.55
7.4.290.0030.00316.62
7.4.280.0000.00816.47
7.4.270.0000.00716.63
7.4.260.0050.00316.59
7.4.250.0000.00816.58
7.4.240.0030.00416.45
7.4.230.0000.00816.70
7.4.220.0070.01216.55
7.4.210.0100.00816.53
7.4.200.0000.00816.53
7.4.160.0030.01316.60
7.4.150.0090.00917.40
7.4.140.0140.00617.86
7.4.130.0100.01116.57
7.4.120.0020.01516.68
7.4.110.0130.01016.52
7.4.100.0110.00716.65
7.4.90.0120.00616.44
7.4.80.0060.01219.39
7.4.70.0090.00916.62
7.4.60.0090.00916.52
7.4.50.0000.00716.34
7.4.40.0040.01416.39
7.4.30.0140.00316.70
7.4.00.0090.00915.04
7.3.330.0000.00613.20
7.3.320.0080.00813.19
7.3.310.0000.00716.45
7.3.300.0000.00716.24
7.3.290.0020.00516.30
7.3.280.0100.00816.38
7.3.270.0100.01617.40
7.3.260.0150.00916.42
7.3.250.0140.00716.53
7.3.240.0040.01316.54
7.3.230.0140.00916.43
7.3.210.0080.01316.61
7.3.200.0110.00519.39
7.3.190.0110.00616.46
7.3.180.0040.01116.67
7.3.170.0190.00016.50
7.3.160.0060.01016.54
7.3.120.0060.01215.04
7.3.110.0160.00314.87
7.3.100.0030.01014.80
7.3.90.0030.00614.86
7.3.80.0080.00414.82
7.3.70.0100.00714.73
7.3.60.0060.00614.99
7.3.50.0030.00914.66
7.3.40.0090.00014.90
7.3.30.0030.00614.92
7.3.20.0070.01116.51
7.3.10.0070.01116.41
7.3.00.0030.00716.86
7.2.330.0040.01416.64
7.2.320.0090.00816.77
7.2.310.0090.00916.79
7.2.300.0130.01016.86
7.2.290.0160.00816.58
7.2.250.0100.00714.88
7.2.240.0100.01014.98
7.2.230.0070.01115.09
7.2.220.0040.00715.04
7.2.210.0070.00414.97
7.2.200.0120.00315.09
7.2.190.0000.01315.18
7.2.180.0000.01015.02
7.2.170.0070.00715.17
7.2.110.0030.01316.74
7.2.60.0250.01316.96
7.2.00.0140.00019.30
7.1.330.0070.00715.69
7.1.320.0030.01015.86
7.1.310.0030.00915.67
7.1.300.0070.00715.60
7.1.290.0000.01215.84
7.1.280.0160.00015.67
7.1.270.0130.00315.61
7.1.260.0060.00315.56
7.1.200.0060.00615.57
7.1.100.0070.01018.01
7.1.70.0030.00617.07
7.1.60.0110.01419.50
7.1.50.0060.01916.89
7.1.00.0070.07322.33
7.0.200.0000.00816.78
7.0.60.0170.07719.88
7.0.50.0030.06717.98
7.0.40.0100.08320.27
7.0.30.0230.05020.12
7.0.20.0400.06720.30
7.0.10.0030.04320.09
7.0.00.0070.07320.23
5.6.280.0030.07321.09
5.6.210.0130.07720.54
5.6.200.0070.08018.20
5.6.190.0130.04020.34
5.6.180.3030.04720.41
5.6.170.0200.03720.47
5.6.160.0000.04320.52
5.6.150.0130.05718.19
5.6.140.0070.08318.21
5.6.130.0100.07018.16
5.6.120.0100.05720.99
5.6.110.0100.07721.13
5.6.100.0070.04321.00
5.6.90.0100.07321.00
5.6.80.0070.04720.44
5.5.350.0330.06020.32
5.5.340.0030.04017.98
5.5.330.0070.05320.40
5.5.320.0370.07720.34
5.5.310.0170.03720.32
5.5.300.0030.06718.07
5.5.290.0100.03318.01
5.5.280.0100.08320.98
5.5.270.0070.04020.77
5.5.260.0100.06720.78
5.5.250.0200.07020.70
5.5.240.0030.03720.03
5.4.450.0170.04719.64
5.4.440.0230.05719.30
5.4.430.0100.03719.41
5.4.420.0030.06319.32
5.4.410.0170.05019.06
5.4.400.0100.05018.89
5.4.390.0070.05718.63
5.4.380.0070.06018.61
5.4.370.0070.05718.74
5.4.360.0130.04718.77
5.4.350.0130.05318.53
5.4.340.0000.06018.54
5.4.320.0100.06018.57
5.4.310.0130.05018.75
5.4.300.0100.05018.56
5.4.290.0170.04318.85
5.4.280.0070.05718.57
5.4.270.0170.04718.75
5.4.260.0230.04018.48
5.4.250.0100.05318.78
5.4.240.0130.05018.62
5.4.230.0070.05318.77
5.4.220.0200.04318.82
5.4.210.0030.06018.82
5.4.200.0230.03716.64
5.4.190.0070.05318.75
5.4.180.0130.04718.72
5.4.170.0030.06018.57
5.4.160.0170.04318.73
5.4.150.0100.05318.77
5.4.140.0000.06316.28
5.4.130.0170.04316.47
5.4.120.0030.05316.38
5.4.110.0070.05016.45
5.4.100.0100.05016.27
5.4.90.0070.05316.30
5.4.80.0100.05016.35
5.4.70.0070.05316.27
5.4.60.0170.04316.22
5.4.50.0100.04716.21
5.4.40.0130.04716.28
5.4.30.0100.05316.12
5.4.20.0030.05716.40
5.4.10.0000.06016.28
5.4.00.0170.05315.92
5.3.290.0170.04714.74
5.3.280.0030.06014.66
5.3.270.0030.06014.60
5.3.260.0000.06314.80
5.3.250.0030.05714.79
5.3.240.0070.05314.75
5.3.230.0070.06314.83
5.3.220.0100.05314.79
5.3.210.0030.06314.57
5.3.200.0100.06714.56
5.3.190.0100.05314.69
5.3.180.0100.05014.60
5.3.170.0170.05014.75
5.3.160.0070.05314.69
5.3.150.0130.04714.82
5.3.140.0100.05314.80
5.3.130.0070.05714.67
5.3.120.0070.05314.70
5.3.110.0070.05714.73
5.3.100.0070.05314.16
5.3.90.0100.05314.26
5.3.80.0100.05014.06
5.3.70.0070.05714.16
5.3.60.0070.05314.19
5.3.50.0100.05714.04
5.3.40.0130.04714.03
5.3.30.0130.04314.00
5.3.20.0130.04713.79
5.3.10.0030.05013.79
5.3.00.0070.05313.68
5.2.170.0100.04011.24
5.2.160.0170.03011.13
5.2.150.0100.04011.18
5.2.140.0070.04311.22
5.2.130.0000.04711.32
5.2.120.0100.03311.10
5.2.110.0100.03711.34
5.2.100.0030.04011.32
5.2.90.0130.04311.17
5.2.80.0030.04311.20
5.2.70.0070.04011.12
5.2.60.0100.04011.15
5.2.50.0030.04711.07
5.2.40.0100.04011.07
5.2.30.0030.05011.01
5.2.20.0170.03011.07
5.2.10.0070.04010.97
5.2.00.0230.02310.82
5.1.60.0100.02710.04
5.1.50.0070.03310.07
5.1.40.0030.03710.00
5.1.30.0100.03310.56
5.1.20.0070.05010.41
5.1.10.0070.04010.09
5.1.00.0130.03310.06
5.0.50.0000.0338.74
5.0.40.0070.0238.51
5.0.30.0070.0438.23
5.0.20.0070.0408.23
5.0.10.0070.0278.16
5.0.00.0000.0478.20
4.4.90.0000.0235.93
4.4.80.0000.0235.88
4.4.70.0030.0205.90
4.4.60.0030.0205.88
4.4.50.0000.0235.95
4.4.40.0000.0375.98
4.4.30.0030.0205.87
4.4.20.0000.0235.95
4.4.10.0030.0205.95
4.4.00.0070.0305.92
4.3.110.0030.0205.86
4.3.100.0070.0175.93
4.3.90.0030.0205.93
4.3.80.0100.0275.80
4.3.70.0000.0235.85
4.3.60.0000.0235.79
4.3.50.0030.0205.83
4.3.40.0100.0275.76
4.3.30.0000.0234.65
4.3.20.0000.0234.53
4.3.10.0000.0234.63
4.3.00.0030.01316.51

preferences:
44.83 ms | 401 KiB | 5 Q