3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<h1>Title 1</h1> <div class="items">some data and divs here 1</div> <h1>Title 2</h1> <div class="items">some data and divs here 2</div> <div class="items">some data and divs here 3</div> <h1>Title 3</h1> <div class="items">some data and divs here 4</div> <div class="items">some data and divs here 5</div> <div class="items">some data and divs here 6</div>'; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXpath($doc); $domNodeList = $xpath->query('/html/body/h1'); $result = []; foreach($domNodeList as $element) { // Save the h1 $item = $element->nodeValue; // Loop the siblings unit the next h1 while ($element = $element->nextSibling) { if ($element->nodeName === "h1") { break; } // if Node is a DOMElement if ($element->nodeType === 1) { $result[] = ['item' => $item, 'data' => $element->nodeValue]; } } } var_export($result);

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.4.120.0100.00918.20
8.4.110.0130.00618.33
8.4.100.0130.00818.22
8.4.90.0110.00920.76
8.4.80.0060.00319.24
8.4.70.0130.00821.02
8.4.60.0130.00920.61
8.4.50.0130.00719.83
8.4.40.0060.01319.97
8.4.30.0080.00819.18
8.4.20.0060.00319.97
8.4.10.0080.01224.35
8.3.250.0100.01017.25
8.3.240.0100.00916.85
8.3.230.0100.00917.15
8.3.220.0130.00519.41
8.3.210.0070.01117.13
8.3.200.0060.00317.16
8.3.190.0110.00917.54
8.3.180.0120.00716.98
8.3.170.0090.00617.84
8.3.160.0150.00418.95
8.3.150.0120.00621.13
8.3.140.0060.00318.86
8.3.130.0030.00617.29
8.3.120.0060.00319.51
8.3.110.0080.00020.94
8.3.100.0040.00424.06
8.3.90.0030.00526.77
8.3.80.0110.00017.00
8.3.70.0120.00916.84
8.3.60.0120.00617.00
8.3.50.0040.01120.28
8.3.40.0140.00420.55
8.3.30.0150.00319.23
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0080.00026.16
8.2.290.0150.00316.96
8.2.280.0060.00418.84
8.2.270.0090.00917.65
8.2.260.0000.01018.67
8.2.250.0080.00017.09
8.2.240.0060.00317.47
8.2.230.0000.00822.58
8.2.220.0040.00437.54
8.2.210.0040.00426.77
8.2.200.0090.00017.00
8.2.190.0150.00317.25
8.2.180.0130.00625.92
8.2.170.0100.01019.46
8.2.160.0090.00622.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0030.00626.16
8.2.110.0090.00021.06
8.2.100.0080.00318.28
8.2.90.0030.00618.25
8.2.80.0050.00319.21
8.2.70.0070.00218.00
8.2.60.0000.00818.43
8.2.50.0000.00818.13
8.2.40.0040.00718.27
8.2.30.0040.00418.59
8.2.20.0040.00421.06
8.2.10.0000.00818.55
8.2.00.0000.00719.69
8.1.330.0140.00716.47
8.1.320.0090.01116.59
8.1.310.0030.01217.06
8.1.300.0000.01918.87
8.1.290.0030.00630.84
8.1.280.0070.01425.92
8.1.270.0000.00724.66
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0060.00624.23
8.1.230.0090.00323.07
8.1.220.0040.00418.28
8.1.210.0050.00318.77
8.1.200.0030.00617.86
8.1.190.0000.00917.72
8.1.180.0100.00718.10
8.1.170.0000.00819.39
8.1.160.0050.00219.42
8.1.150.0000.00819.02
8.1.140.0030.00617.88
8.1.130.0000.00717.80
8.1.120.0050.00517.77
8.1.110.0140.00317.79
8.1.100.0140.00217.79
8.1.90.0100.00617.84
8.1.80.0130.00317.86
8.1.70.0130.00517.83
8.1.60.0150.00517.87
8.1.50.0170.00217.92
8.1.40.0090.01017.80
8.1.30.0110.00617.96
8.1.20.0170.00217.92
8.1.10.0130.00517.87
8.1.00.0150.00617.88
8.0.300.0070.00020.16
8.0.290.0050.00317.25
8.0.280.0070.00018.85
8.0.270.0000.00818.37
8.0.260.0030.00317.24
8.0.250.0120.00417.13
8.0.240.0110.00517.16
8.0.230.0120.00617.19
8.0.220.0090.00817.19
8.0.210.0100.00717.03
8.0.200.0120.00417.17
8.0.190.0060.01017.19
8.0.180.0140.00417.12
8.0.170.0080.00717.20
8.0.160.0150.00317.27
8.0.150.0130.00717.15
8.0.140.0160.00217.11
8.0.130.0120.00417.09
8.0.120.0110.00617.17
8.0.110.0140.00517.23
8.0.100.0070.01117.22
8.0.90.0170.00317.09
8.0.80.0140.00717.27
8.0.70.0140.00417.18
8.0.60.0150.00417.12
8.0.50.0150.00317.04
8.0.30.0100.00717.22
8.0.20.0140.00417.24
8.0.10.0100.00917.27
7.4.330.0030.00315.55
7.4.320.0150.00316.83
7.4.300.0110.00716.81
7.4.290.0130.00616.82
7.4.280.0130.00816.93
7.4.270.0140.00416.82
7.4.260.0170.00216.81
7.4.250.0160.00416.91
7.4.240.0120.00616.75
7.4.230.0120.00716.84
7.4.220.0120.00516.89
7.4.210.0110.00516.96
7.4.200.0130.00516.80
7.4.190.0160.00316.85
7.4.180.0050.01116.77
7.4.160.0140.00516.87
7.4.150.0140.00516.75
7.4.140.0150.00216.77
7.4.130.0090.00716.68
7.4.120.0120.00416.70
7.4.110.0160.00116.85
7.4.100.0130.00416.83
7.4.90.0130.00416.77
7.4.80.0110.00516.71
7.4.70.0100.00916.78
7.4.60.0080.00816.79
7.4.50.0130.00316.71
7.4.40.0130.00516.78
7.4.30.0120.00216.75
7.4.20.0110.00316.84
7.4.10.0060.00716.73
7.4.00.0100.00416.75

preferences:
30.26 ms | 403 KiB | 5 Q