3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <p>Paragraph one is okay </p> <h2>This will work without problem</h2> <p>Paragraph two is okay </p> <h2><a href="#">This heading has anchor</a></h2> <p>Paragraph one is okay </p> <h2> This heading start with space</h2> <p>Paragraph two is okay </p> <h3>1. <a href="https://www.example1.com/">This wont work</a></h3> <p>Paragraph one is okay </p> <h3>2. <a href="https://www.example2.com/">Not working</a></h3> <p>Paragraph two is okay </p> <h3>3. Neither this one</h3> <h3>But this works again</h3> </div> HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//h2 | //h3") as $node) { if (preg_match('~^\s*(?:\d+\.)?\s*\K\S+(?:\s+\S+){1,2}~', $node->nodeValue, $m)) { $node->setAttribute('id', str_replace(' ', '-', strtolower($m[0]))); } } echo $dom->saveHTML();

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.0110.00417.12
8.3.50.0060.01218.44
8.3.40.0110.00719.62
8.3.30.0040.01119.30
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.180.0080.00825.92
8.2.170.0140.00719.58
8.2.160.0070.00722.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0080.00021.25
8.2.110.0060.00322.64
8.2.100.0090.00318.34
8.2.90.0030.00719.86
8.2.80.0050.00318.38
8.2.70.0030.00618.38
8.2.60.0000.01118.43
8.2.50.0040.00418.25
8.2.40.0070.00318.72
8.2.30.0040.00418.59
8.2.20.0060.00318.59
8.2.10.0040.00419.68
8.2.00.0060.00319.69
8.1.280.0070.01125.92
8.1.270.0030.00624.41
8.1.260.0040.01126.35
8.1.250.0080.00028.09
8.1.240.0030.00724.21
8.1.230.0120.00024.48
8.1.220.0040.00418.29
8.1.210.0080.00018.77
8.1.200.0030.00617.85
8.1.190.0050.00317.85
8.1.180.0030.00618.10
8.1.170.0040.00419.14
8.1.160.0000.00819.38
8.1.150.0080.00019.34
8.1.140.0000.00821.21
8.1.130.0080.00018.02
8.1.120.0000.00718.11
8.1.110.0090.00018.04
8.1.100.0040.00417.92
8.1.90.0040.00418.11
8.1.80.0040.00418.04
8.1.70.0030.00717.94
8.1.60.0040.00418.21
8.1.50.0030.00618.02
8.1.40.0000.00818.02
8.1.30.0000.00818.28
8.1.20.0060.00318.15
8.1.10.0000.00818.07
8.1.00.0030.00518.12
8.0.300.0090.00019.27
8.0.290.0040.00417.38
8.0.280.0070.00018.81
8.0.270.0040.00418.59
8.0.260.0030.00317.55
8.0.250.0030.00517.62
8.0.240.0000.00717.52
8.0.230.0070.00017.52
8.0.220.0070.00017.59
8.0.210.0080.00017.43
8.0.200.0000.00717.55
8.0.190.0030.00517.54
8.0.180.0050.00317.61
8.0.170.0030.00617.51
8.0.160.0000.00717.65
8.0.150.0000.00717.43
8.0.140.0040.00417.54
8.0.130.0030.00313.97
8.0.120.0000.00817.47
8.0.110.0040.00417.33
8.0.100.0030.00517.54
8.0.90.0040.00417.58
8.0.80.0090.00817.50
8.0.70.0000.00717.32
8.0.60.0000.00817.47
8.0.50.0080.00017.43
8.0.30.0060.01217.69
8.0.20.0150.00817.67
8.0.10.0040.00417.69
8.0.00.0030.01917.22
7.4.330.0000.00615.59
7.4.320.0030.00317.24
7.4.300.0040.00417.27
7.4.290.0000.00717.19
7.4.280.0080.00017.19
7.4.270.0000.00717.23
7.4.260.0060.00013.96
7.4.250.0040.00417.25
7.4.240.0030.00417.20
7.4.230.0080.00017.36
7.4.220.0020.00517.07
7.4.210.0050.01117.26
7.4.200.0050.00317.32
7.4.130.0110.00617.24
7.4.120.0200.00417.17
7.4.110.0120.00617.17
7.4.100.0120.00917.18
7.4.90.0040.01317.11
7.4.80.0110.00819.39
7.4.70.0030.01517.28
7.4.60.0220.00416.75
7.4.50.0210.00516.98
7.4.40.0200.00716.61
7.4.30.0130.01017.00
7.4.20.0140.01117.05
7.4.10.0130.01316.85
7.4.00.0040.01617.14
7.3.330.0030.00516.75
7.3.320.0000.00513.73
7.3.310.0030.00316.76
7.3.300.0000.00717.02
7.3.290.0110.00616.82
7.3.260.0140.00416.87
7.3.240.0100.00917.01
7.3.230.0150.00917.00
7.3.210.0110.00717.06
7.3.200.0070.01316.96
7.3.190.0140.00316.86
7.3.180.0090.01316.81
7.3.170.0190.01016.98
7.3.160.0090.01717.13
7.3.150.0110.01816.79
7.3.140.0210.00617.03
7.3.130.0130.01316.92
7.3.120.0190.00316.89
7.3.110.0200.00316.85
7.3.100.0100.01316.80
7.3.90.0110.01116.86
7.3.80.0150.01016.82
7.3.70.0200.00316.55
7.3.60.0200.00316.87
7.3.50.0160.00616.66
7.3.40.0090.01216.93
7.3.30.0150.00716.69
7.3.20.0120.01216.96
7.3.10.0170.00916.79
7.3.00.0290.00016.86
7.2.330.0060.01317.24
7.2.320.0130.00917.36
7.2.310.0170.00717.23
7.2.300.0160.01517.07
7.2.290.0090.01417.28
7.2.280.0140.01017.11
7.2.270.0100.01616.94
7.2.260.0130.01117.28
7.2.250.0160.00717.14
7.2.240.0160.00816.94
7.2.230.0190.00317.01
7.2.220.0170.00617.05
7.2.210.0110.01516.79
7.2.200.0170.00716.91
7.2.190.0070.01517.04
7.2.180.0080.01617.18
7.2.170.0190.00817.16
7.2.160.0150.00817.15
7.2.150.0180.00716.98
7.2.140.0200.00516.96
7.2.130.0110.01917.20
7.2.120.0190.00817.16
7.2.110.0200.00417.10
7.2.100.0700.00417.08
7.2.90.0130.01016.94
7.2.80.0170.00816.98
7.2.70.0200.01016.72
7.2.60.0200.00716.96
7.2.50.0110.01517.11
7.2.40.0200.00716.91
7.2.30.0250.00417.09
7.2.20.0190.00617.11
7.2.10.0150.01116.98
7.2.00.0210.00717.01

preferences:
40.38 ms | 400 KiB | 5 Q