3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOT <body> <div class="page-content"> First text <p>Second text</p> <div>Third text</div> <p>More text</p> <h4>Subtitle 1</h4> <p>bla bla</p> <p>bla bla</p> <h4>Subtitle 2</h4> <p>bla bla</p> <p>bla bla</p> </div> </body> EOT; $doc = new DOMDocument(); $doc->loadHTML($html); // Get our node by class name // See https://stackoverflow.com/a/6366390/231316 $finder = new DomXPath($doc); $classname = "page-content"; $nodes = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]"); $buf = ''; foreach ($nodes as $node) { foreach ($node->childNodes as $child) { if ($child->nodeName === 'h4') { break; } $buf .= $doc->saveHTML($child); } } echo $buf;

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.140.0120.00818.13
8.4.130.0110.01018.20
8.4.120.0080.00924.51
8.4.110.0060.00423.03
8.4.100.0100.01019.27
8.4.90.0140.00619.18
8.4.80.0050.00519.24
8.4.70.0110.00918.19
8.4.60.0110.01118.36
8.4.50.0130.00819.81
8.4.40.0040.00419.79
8.4.30.0060.00320.83
8.4.20.0100.01020.01
8.4.10.0030.00624.11
8.3.270.0110.00916.99
8.3.260.0120.00416.91
8.3.250.0070.01119.13
8.3.240.0070.01217.53
8.3.230.0090.00416.95
8.3.220.0060.00219.38
8.3.210.0110.00816.95
8.3.200.0090.00916.85
8.3.190.0040.00517.06
8.3.180.0090.00916.76
8.3.170.0130.00617.70
8.3.160.0140.00017.26
8.3.150.0120.00619.14
8.3.140.0090.00917.57
8.3.130.0060.00318.77
8.3.120.0030.00621.07
8.3.110.0080.00020.94
8.3.100.0040.00417.00
8.3.90.0150.00026.77
8.3.80.0070.00318.81
8.3.70.0120.00417.25
8.3.60.0070.00718.48
8.3.50.0140.01018.72
8.3.40.0120.00320.59
8.3.30.0090.00619.08
8.3.20.0070.00024.18
8.3.10.0000.00824.66
8.3.00.0070.00326.16
8.2.290.0110.00820.95
8.2.280.0090.01017.10
8.2.270.0120.00616.91
8.2.260.0030.00619.25
8.2.250.0040.00416.86
8.2.240.0090.00917.71
8.2.230.0170.00322.58
8.2.220.0100.01324.06
8.2.210.0040.01526.77
8.2.200.0060.00316.88
8.2.190.0160.00616.88
8.2.180.0060.00925.92
8.2.170.0070.00719.33
8.2.160.0110.00422.96
8.2.150.0080.00025.66
8.2.140.0080.00024.66
8.2.130.0050.01426.16
8.2.120.0040.00421.39
8.2.110.0030.00719.71
8.2.100.0000.01318.16
8.2.90.0060.00318.22
8.2.80.0080.00019.69
8.2.70.0000.00817.88
8.2.60.0080.00017.87
8.2.50.0060.00318.00
8.2.40.0140.00318.00
8.2.30.0120.00618.00
8.2.20.0000.01617.88
8.2.10.0100.00617.88
8.2.00.0150.00317.63
8.1.330.0120.00722.45
8.1.320.0130.00718.33
8.1.310.0040.00817.35
8.1.300.0160.00318.48
8.1.290.0000.01430.84
8.1.280.0070.00725.92
8.1.270.0000.00824.66
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0000.00922.58
8.1.230.0110.00021.22
8.1.220.0060.00618.18
8.1.210.0040.00419.28
8.1.200.0040.00417.85
8.1.190.0030.00617.73
8.1.180.0030.00618.10
8.1.170.0120.00417.63
8.1.160.0050.01117.63
8.1.150.0000.01617.62
8.1.140.0090.00917.62
8.1.130.0150.00417.62
8.1.120.0100.00717.63
8.1.110.0070.01017.63
8.1.100.0170.00017.62
8.1.90.0100.00717.62
8.1.80.0150.00217.63
8.1.70.0140.00317.62
8.1.60.0130.00617.62
8.1.50.0090.00917.84
8.1.40.0090.00917.86
8.1.30.0100.00717.73
8.1.20.0180.00017.85
8.1.10.0170.00017.88
8.1.00.0150.00417.75
8.0.300.0070.00020.67
8.0.290.0000.00917.13
8.0.280.0130.00417.62
8.0.270.0130.00417.62
8.0.260.0140.00317.62
8.0.250.0160.00017.62
8.0.240.0080.00817.62
8.0.230.0070.00717.62
8.0.220.0120.00417.62
8.0.210.0080.00817.62
8.0.200.0140.00517.62
8.0.190.0110.00517.62
8.0.180.0160.00017.62
8.0.170.0160.00017.62
8.0.160.0120.00417.62
8.0.150.0100.00717.62
8.0.140.0160.00217.62
8.0.130.0110.00617.62
8.0.120.0130.00817.62
8.0.110.0150.00017.62
8.0.100.0060.01217.62
8.0.90.0140.00217.62
8.0.80.0130.00317.62
8.0.70.0090.00917.62
8.0.60.0110.00517.62
8.0.50.0100.00717.62
8.0.30.0070.01017.62
8.0.20.0100.00617.62
8.0.10.0170.00017.62
7.4.190.0050.00516.74
5.6.400.0230.00916.20

preferences:
30.45 ms | 403 KiB | 5 Q