3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo '<pre>'; $html = " <p>consectetur <b>adipisc<i>in</i>g </b>elit. Maecenas sit amet molestie enim. Nulla gravida mi sed ipsum </p> <p>pellentesque<br>ut pulvinar orci consequat. Donec tempus rutrum urna at iaculis. Ut sagittis, tellus eu venenatis imperdiet,</p> <ol> <li> <ol> <li><b></b></li> <li>sdaf</li> </ol> sem dolor mattis leo, </li> <li>in consequat elit lorem ut ligula.</li> </ol> Praessadf"; echo $html."<br>"; var_dump(check_html($html)); function check_html($html) { $tags = array(); preg_match_all('#<(/?[a-zA-Z]+)\b.*?>#im', $html, $tags); $tags = array_map('strtolower', $tags[1]); $lists = array('ul', 'ol'); $single_tags = array('br'); $tags_stack = new SplStack(); $lists_stack = new SplStack(); foreach ($tags as $tag) { if ($tag[0] != '/') { // start tag if (in_array($tag, $single_tags)) { // if single tag, just continue continue; } elseif (in_array($tag, $lists)) { $lists_stack->push($tag); // new list starts } $tags_stack->push($tag); } else { // end tag if (!$tags_stack->count()) { return false; // there aren't opened tags } $end_tag = trim($tag, '/'); // handle lists if (in_array($end_tag, $lists)) { if (!$lists_stack->count() || $lists_stack->pop() != $end_tag) { return false; // there are no opened lists or unclosed list tag } } elseif ($end_tag == 'li') { if (!$lists_stack->count()) { return false; // there are no opened lists } } if ($tags_stack->pop() != $end_tag) { return false; // unclosed tag } } } return !$tags_stack->count(); // true if stack is empty }

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.0070.00718.56
8.3.60.0060.01216.63
8.3.50.0100.01222.06
8.3.40.0120.00418.96
8.3.30.0090.00919.22
8.3.20.0050.00220.29
8.3.10.0000.00823.48
8.3.00.0040.00420.64
8.2.180.0090.00618.43
8.2.170.0120.00622.96
8.2.160.0100.00722.25
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00422.29
8.2.110.0030.00622.33
8.2.100.0090.00317.72
8.2.90.0030.00619.17
8.2.80.0000.00818.16
8.2.70.0000.00817.75
8.2.60.0030.00617.93
8.2.50.0080.00018.07
8.2.40.0040.00418.34
8.2.30.0050.00218.16
8.2.20.0000.00717.87
8.2.10.0060.00319.63
8.2.00.0050.00217.97
8.1.280.0100.00725.92
8.1.270.0080.00023.86
8.1.260.0030.00626.35
8.1.250.0030.00528.09
8.1.240.0060.00323.84
8.1.230.0080.00319.16
8.1.220.0050.00317.78
8.1.210.0050.00318.77
8.1.200.0030.00717.60
8.1.190.0000.01017.53
8.1.180.0000.00818.10
8.1.170.0000.00818.76
8.1.160.0000.00821.93
8.1.150.0000.00718.80
8.1.140.0040.00417.62
8.1.130.0030.00317.76
8.1.120.0050.00317.64
8.1.110.0080.00017.50
8.1.100.0000.00717.52
8.1.90.0000.00717.51
8.1.80.0080.00017.60
8.1.70.0030.00317.51
8.1.60.0080.00017.68
8.1.50.0030.00517.68
8.1.40.0090.00017.68
8.1.30.0080.00017.70
8.1.20.0000.00817.72
8.1.10.0060.00317.67
8.1.00.0040.00417.70
8.0.300.0080.00018.77
8.0.290.0040.00416.93
8.0.280.0070.00018.48
8.0.270.0030.00317.25
8.0.260.0040.00416.91
8.0.250.0030.00316.99
8.0.240.0000.00717.13
8.0.230.0040.00417.10
8.0.220.0000.00717.03
8.0.210.0040.00417.04
8.0.200.0070.00017.10
8.0.190.0070.00017.00
8.0.180.0070.00016.98
8.0.170.0040.00417.10
8.0.160.0040.00416.92
8.0.150.0030.00717.00
8.0.140.0000.00717.05
8.0.130.0030.00313.52
8.0.120.0000.00816.92
8.0.110.0040.00416.94
8.0.100.0000.00716.94
8.0.90.0050.00516.95
8.0.80.0040.01117.10
8.0.70.0040.00417.03
8.0.60.0030.00517.04
8.0.50.0090.00017.14
8.0.30.0180.00517.43
8.0.20.0070.01217.40
8.0.10.0030.00517.06
8.0.00.0100.01316.73
7.4.330.0050.00015.10
7.4.320.0060.00016.73
7.4.300.0000.00616.80
7.4.290.0030.00516.87
7.4.280.0000.00716.64
7.4.270.0030.00516.72
7.4.260.0030.00316.67
7.4.250.0000.00916.80
7.4.240.0000.00716.71
7.4.230.0070.00016.71
7.4.220.0070.01116.91
7.4.210.0070.00916.71
7.4.200.0070.00016.66
7.4.190.0040.00416.99
7.4.160.0060.01116.71
7.4.150.0090.00917.40
7.4.140.0080.01117.86
7.4.130.0130.01516.82
7.4.120.0120.00616.79
7.4.110.0120.00616.80
7.4.100.0070.01116.86
7.4.90.0170.00816.65
7.4.80.0080.01516.48
7.4.70.0060.01516.69
7.4.60.0120.00616.67
7.4.50.0060.00316.54
7.4.40.0110.00422.77
7.4.30.0040.01416.78
7.4.00.0030.01315.24
7.3.330.0000.00613.39
7.3.320.0030.00313.60
7.3.310.0000.00716.39
7.3.300.0070.00016.58
7.3.290.0060.01516.46
7.3.280.0070.01116.45
7.3.270.0060.01017.40
7.3.260.0030.01316.81
7.3.250.0100.01116.64
7.3.240.0110.01116.76
7.3.230.0060.01016.48
7.3.210.0030.01516.43
7.3.200.0110.00819.39
7.3.190.0040.01216.60
7.3.180.0030.01516.86
7.3.170.0100.00616.55
7.3.160.0060.00916.59
7.3.120.0060.00615.00
7.2.330.0060.01216.84
7.2.320.0100.00717.11
7.2.310.0110.00716.89
7.2.300.0060.01116.87
7.2.290.0100.01316.99
7.2.00.0060.00619.49
7.1.200.0060.00916.07
7.1.100.0070.00418.50
7.1.70.0000.00717.55
7.1.60.0030.02219.27
7.1.50.0100.01017.25
7.1.00.0030.07322.38
7.0.200.0030.00316.88
7.0.140.0070.07322.09
7.0.100.0030.04019.93
7.0.90.0030.09320.07
7.0.80.0170.05719.90
7.0.70.0030.06720.02
7.0.60.0100.08020.02
7.0.50.0170.07320.39
7.0.40.0000.06720.05
7.0.30.0030.04319.95
7.0.20.0030.07320.19
7.0.10.0070.08020.10
7.0.00.0000.04719.94
5.6.280.0030.09020.88
5.6.250.0100.06320.55
5.6.240.0070.07320.62
5.6.230.0170.07020.70
5.6.220.0030.08720.60
5.6.210.0130.07020.50
5.6.200.0070.08321.10
5.6.190.0070.06321.05
5.6.180.0070.04021.10
5.6.170.0000.08321.05
5.6.160.0030.08321.10
5.6.150.0100.05721.06
5.6.140.0100.07721.19
5.6.130.0000.07320.95
5.6.120.0000.08721.13
5.6.110.0100.03321.14
5.6.100.0100.04320.96
5.6.90.0100.08321.08
5.6.80.0100.05020.58
5.6.70.0100.06320.50
5.6.60.0100.08020.48
5.6.50.0030.07320.42
5.6.40.0030.07720.38
5.6.30.0100.04320.38
5.6.20.0100.07720.54
5.6.10.0030.08720.41
5.6.00.0030.05020.43
5.5.380.0030.04320.42
5.5.370.0030.06320.38
5.5.360.0100.08020.49
5.5.350.0130.04320.48
5.5.340.0000.08020.90
5.5.330.0070.04720.92
5.5.320.0000.08320.97
5.5.310.0130.07320.85
5.5.300.0070.03720.81
5.5.290.0070.07720.91
5.5.280.0070.05320.81
5.5.270.0130.04020.84
5.5.260.0030.04320.84
5.5.250.0030.05020.75
5.5.240.0070.07020.33
5.5.230.0070.07020.31
5.5.220.0200.07720.17
5.5.210.0030.04320.28
5.5.200.0130.07320.23
5.5.190.0100.08020.14
5.5.180.0130.04020.14
5.5.160.0070.06720.01
5.5.150.0070.06320.20
5.5.140.0070.07720.26
5.5.130.0070.04320.30
5.5.120.0170.05020.24
5.5.110.0030.05020.10
5.5.100.0100.08020.13
5.5.90.0100.07720.18
5.5.80.0230.05720.07
5.5.70.0170.07020.17
5.5.60.0000.08020.11
5.5.50.0070.06020.08
5.5.40.0100.04319.96
5.5.30.0170.05020.17
5.5.20.0130.06320.19
5.5.10.0030.08720.02
5.5.00.0100.04319.97
5.4.450.0100.06719.49
5.4.440.0030.08019.52
5.4.430.0070.06019.22
5.4.420.0000.05719.48
5.4.410.0030.08319.33
5.4.400.0030.07719.16
5.4.390.0030.04319.09
5.4.380.0130.07019.04
5.4.370.0100.07019.21
5.4.360.0100.04319.04
5.4.350.0100.06319.05
5.4.340.0100.03719.13
5.4.320.0070.04319.04
5.4.310.0100.06719.12
5.4.300.0070.07019.09
5.4.290.0070.08019.18
5.4.280.0070.03718.88
5.4.270.0130.07018.95
5.4.260.0000.05719.13
5.4.250.0170.06019.04
5.4.240.0070.05319.18
5.4.230.0130.04019.02
5.4.220.0100.08319.11
5.4.210.0030.05319.04
5.4.200.0030.05719.03
5.4.190.0030.04019.07
5.4.180.0000.05019.17
5.4.170.0030.04018.89
5.4.160.0130.06718.89
5.4.150.0130.06719.03
5.4.140.0100.04016.41
5.4.130.0100.07016.35
5.4.120.0070.07016.24
5.4.110.0070.03316.50
5.4.100.0070.07716.36
5.4.90.0030.05316.42
5.4.80.0030.04316.45
5.4.70.0070.07016.27
5.4.60.0000.07716.48
5.4.50.0130.05316.49
5.4.40.0030.07016.39
5.4.30.0030.04316.25
5.4.20.0170.06716.37
5.4.10.0070.07716.33
5.4.00.0070.07015.86
5.3.290.0030.04714.70
5.3.280.0070.07714.71
5.3.270.0000.05714.73
5.3.260.0030.04714.75
5.3.250.0070.08014.57
5.3.240.0170.06014.60
5.3.230.0030.04314.61
5.3.220.0100.07314.73
5.3.210.0100.07014.52
5.3.200.0030.06714.65
5.3.190.0070.04014.57
5.3.180.0130.07014.65
5.3.170.0070.07714.67
5.3.160.0070.04014.73
5.3.150.0100.06014.57
5.3.140.0000.08014.63
5.3.130.0000.04714.64
5.3.120.0100.07314.70
5.3.110.0100.07314.68
5.3.100.0070.05014.20
5.3.90.0030.07013.98
5.3.80.0070.06314.04
5.3.70.0170.03014.04
5.3.60.0000.05014.00
5.3.50.0100.02714.00
5.3.40.0100.06714.00
5.3.30.0030.05714.06
5.3.20.0070.05013.85
5.3.10.0130.06713.81
5.3.00.0070.05713.64
5.2.170.0030.06312.74
5.2.160.0070.06012.74
5.2.150.0030.03712.74
5.2.140.0030.05012.74
5.2.130.0000.04712.74
5.2.120.0030.04712.74
5.2.110.0130.05712.74
5.2.100.0070.03312.74
5.2.90.0070.03012.74
5.2.80.0030.05712.74
5.2.70.0070.03712.74
5.2.60.0070.03312.74
5.2.50.0000.03312.74
5.2.40.0030.04012.74
5.2.30.0030.03012.74
5.2.20.0070.06012.74
5.2.10.0000.04312.74
5.2.00.0030.03012.74
5.1.60.0000.04012.74
5.1.50.0070.03012.74
5.1.40.0030.04012.74
5.1.30.0030.05712.74
5.1.20.0070.02712.74
5.1.10.0070.04712.74
5.1.00.0000.05312.74
5.0.50.0000.05012.74
5.0.40.0030.04312.74
5.0.30.0070.04712.74
5.0.20.0030.01712.74
5.0.10.0030.02712.74
5.0.00.0030.03012.74
4.4.90.0070.02712.74
4.4.80.0000.02712.74
4.4.70.0000.02012.74
4.4.60.0070.01312.74
4.4.50.0100.02712.74
4.4.40.0030.03012.74
4.4.30.0030.01712.74
4.4.20.0070.03012.74
4.4.10.0000.02312.74
4.4.00.0000.03012.74
4.3.110.0070.02312.74
4.3.100.0030.01312.74
4.3.90.0030.02712.74
4.3.80.0030.02712.74
4.3.70.0030.01312.74
4.3.60.0000.03312.74
4.3.50.0030.02012.74
4.3.40.0000.03012.74
4.3.30.0000.03012.74
4.3.20.0030.01712.74
4.3.10.0030.02012.74
4.3.00.0030.03012.74

preferences:
97.49 ms | 401 KiB | 5 Q