3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<EOF <table class="track_list track_table" id="track_table"> <tbody> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">1.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/i-feel">I Feel</a> 04:18</div> </td> <td> <div class="info_link" style="visibility:visible">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:visible">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">2.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/wait">Wait</a> 06:03</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">3.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/superwoman">Superwoman</a> 03:46</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">4.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/in-the-night">In The Night</a> 05:41</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">5.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/what-to-do">What To Do</a> 03:52</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">6.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/its-been-a-while">It&#39;s Been A While</a> 05:49</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">7.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/move-on">Move On</a> 04:28</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">8.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/loverboy">Loverboy</a> 08:00</div> </td> <td> <div class="info_link" style="visibility:hidden">&nbsp;</div> </td> <td> <div class="dl_link" style="visibility:hidden">&nbsp;</div> </td> </tr> <tr> <td> <div class="play_status">&nbsp;</div> </td> <td> <div class="secondaryText track_number">9.</div> </td> <td> <div class="title"><a href="https://zars.bandcamp.com/track/parallel-world">Parallel World</a> 07:38</div> </td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </tbody> </table> EOF; $data = str_replace(["\r", "\n", "\t"], "", $data); $doc = new DOMDocument(); $doc->loadHTML('<div>' . $data . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new \DOMXpath($doc); // Remove all empty nodes $emptyNodes = $xpath->query("//text()[translate(normalize-space(.), '\"\xC2\xA0\', '') = '']"); foreach ($emptyNodes as $i => $node) { $node->parentNode->parentNode->removeChild($node->parentNode); } $list = $xpath->query(".//text()[translate(normalize-space(.), '\"\xC2\xA0\', '') != '']"); print_r("List size: $list->length \r\n"); function flattenDOMNodes(\DOMDocument &$doc, \DOMNodeLIst $list) { foreach ($list as $i => $node) { print_r("$i\r\n"); $parent = $node->parentNode; // Do not manipulate nodes directly under the root node to separate between tracks. if ($parent->parentNode !== $node->ownerDocument->documentElement) { if ($parent->previousSibling instanceof DOMText) { print_r("Also appending happens!\r\n"); $parent->previousSibling->appendData($node->nodeValue); $parent->parentNode->removeChild($parent); } elseif ($parent->nextSibling instanceof DOMText) { print_r("Also inserting happens!\r\n"); $parent->nextSibling->insertData(0, " $node->nodeValue "); $parent->parentNode->removeChild($parent); } else { $newNode = $doc->createTextNode($node->nodeValue); // Go up one level while ($parent->parentNode->childNodes->length === 1) { print_r("Up, up, up!\r\n"); $parent = $parent->parentNode; } print_r("This happens\r\n"); $parent->replaceChild($newNode, $parent->childNodes->item(0)); } } $xpath = new \DOMXpath($doc); $list = $xpath->query(".//text()[translate(normalize-space(.), '\"\xC2\xA0\', '') != '']"); } return $list; } var_dump(flattenDOMNodes($doc, $list)); var_dump($doc->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.4.20.0070.01119.64
8.4.10.0080.00818.15
8.3.150.0120.00921.24
8.3.140.0070.01017.19
8.3.130.0040.00416.92
8.3.120.0070.01019.60
8.3.110.0090.00017.15
8.3.100.0030.00717.54
8.3.90.0120.00326.77
8.3.80.0070.00417.97
8.3.70.0100.01017.38
8.3.60.0100.01018.80
8.3.50.0080.00818.63
8.3.40.0100.00719.34
8.3.30.0100.00619.21
8.3.20.0040.00422.35
8.3.10.0030.00524.16
8.3.00.0050.00323.98
8.2.270.0100.01017.43
8.2.260.0080.00819.44
8.2.250.0030.00617.02
8.2.240.0100.01017.68
8.2.230.0060.00320.94
8.2.220.0000.01037.54
8.2.210.0040.00426.77
8.2.200.0050.00917.25
8.2.190.0100.01317.13
8.2.180.0100.00618.79
8.2.170.0100.00619.43
8.2.160.0070.00722.96
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0080.00026.16
8.2.120.0070.00421.38
8.2.110.0080.00321.44
8.2.100.0090.00318.22
8.2.90.0030.00618.53
8.2.80.0030.00718.00
8.2.70.0030.00618.43
8.2.60.0030.00618.43
8.2.50.0030.00618.66
8.2.40.0040.00721.36
8.2.30.0030.00519.70
8.2.20.0040.00418.68
8.2.10.0000.00818.57
8.2.00.0030.00618.55
8.1.310.0060.00620.48
8.1.300.0060.00319.21
8.1.290.0050.00530.84
8.1.280.0160.00325.92
8.1.270.0060.00324.35
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0070.00322.83
8.1.230.0060.00621.26
8.1.220.0000.00818.41
8.1.210.0080.00019.47
8.1.200.0060.00317.86
8.1.190.0000.01017.85
8.1.180.0040.00418.10
8.1.170.0040.00418.97
8.1.160.0050.00319.32
8.1.150.0030.00621.20
8.1.140.0090.00018.14
8.1.130.0000.00720.70
8.1.120.0040.00417.91
8.1.110.0050.00317.98
8.1.100.0030.00618.00
8.1.90.0030.00517.91
8.1.80.0040.00418.05
8.1.70.0030.00618.01
8.1.60.0030.00618.07
8.1.50.0070.00418.04
8.1.40.0000.00818.01
8.1.30.0060.00618.18
8.1.20.0000.00918.08
8.1.10.0080.00018.14
8.1.00.0040.00417.91
8.0.300.0050.00320.33
8.0.290.0040.00417.25
8.0.280.0040.00418.90
8.0.270.0000.00817.28
8.0.260.0000.00818.93
8.0.250.0000.00817.40
8.0.240.0000.00817.44
8.0.230.0000.00817.41
8.0.220.0000.00817.36
8.0.210.0070.00017.36
8.0.200.0080.00317.50
8.0.190.0000.00817.39
8.0.180.0040.00417.38
8.0.170.0050.00517.40
8.0.160.0000.00817.53
8.0.150.0000.00817.30
8.0.140.0040.00417.39
8.0.130.0050.00213.86
8.0.120.0040.00417.41
8.0.110.0050.00317.58
8.0.100.0000.00817.19
8.0.90.0000.00817.33
8.0.80.0160.00717.36
8.0.70.0030.00617.41
8.0.60.0000.00817.38
8.0.50.0040.00417.38
8.0.30.0090.01117.69
8.0.20.0080.01417.66
8.0.10.0030.00617.41
8.0.00.0110.00817.22
7.4.330.0000.00617.08
7.4.320.0040.00417.04
7.4.300.0040.00417.06
7.4.290.0000.00817.09
7.4.280.0040.00416.96
7.4.270.0000.00717.01
7.4.260.0000.00916.95
7.4.250.0040.00416.93
7.4.240.0030.00516.96
7.4.230.0040.00417.06
7.4.220.0000.00817.21
7.4.210.0090.00617.08
7.4.200.0040.00416.87
7.4.160.0090.00917.02
7.4.140.0110.00817.86
7.4.130.0060.01316.91
7.4.120.0120.00917.08
7.4.110.0110.00717.02
7.4.100.0140.01017.16
7.4.90.0100.01116.86
7.4.80.0060.02119.39
7.4.70.0150.00717.06
7.4.60.0150.00317.04
7.4.50.0120.00616.90
7.4.40.0090.01517.17
7.4.00.0080.00915.36
7.3.330.0030.00313.69
7.3.320.0040.00413.80
7.3.310.0040.00416.91
7.3.300.0000.00816.86
7.3.290.0040.00416.79
7.3.280.0070.01216.84
7.3.260.0170.01517.00
7.3.240.0070.01117.04
7.3.230.0070.01116.92
7.3.210.0190.00016.84
7.3.200.0110.01017.02
7.3.190.0100.00716.83
7.3.180.0150.00317.02
7.3.170.0070.01116.82
7.3.160.0030.01316.90
7.3.120.0110.01115.04
7.3.110.0030.01015.39
7.3.100.0070.01414.99
7.3.90.0060.01015.13
7.3.80.0060.01315.32
7.3.70.0060.01015.29
7.3.60.0000.01315.09
7.3.50.0030.01315.18
7.3.40.0060.00915.17
7.3.30.0150.00315.05
7.3.20.0120.00316.97
7.3.10.0090.00316.98
7.3.00.0000.01516.93
7.2.330.0090.00916.94
7.2.320.0100.01717.29
7.2.310.0130.00717.19
7.2.300.0140.00317.34
7.2.290.0120.00617.25
7.2.250.0080.01315.59
7.2.240.0030.01715.58
7.2.230.0060.00915.42
7.2.220.0060.00615.48
7.2.210.0030.01315.38
7.2.200.0000.01515.36
7.2.190.0160.00315.42
7.2.180.0070.00315.24
7.2.170.0040.01115.48
7.2.160.0030.00915.46
7.2.150.0110.00316.96
7.2.140.0060.00617.13
7.2.130.0100.00717.43
7.2.120.0100.00717.43
7.2.110.0030.01216.95
7.2.100.0100.00317.26
7.2.90.0090.00317.33
7.2.80.0060.00617.27
7.2.70.0040.00817.26
7.2.60.0090.00517.02
7.2.50.0080.00617.29
7.2.40.2130.01017.83
7.2.30.1760.01117.66
7.2.20.1990.00917.80
7.2.10.1780.01317.69
7.2.00.1860.00717.53
7.1.330.0030.01715.96
7.1.320.0040.01416.10
7.1.310.0090.00915.89
7.1.300.0060.00916.15
7.1.290.0000.01115.73
7.1.280.0090.00916.12
7.1.270.0040.01115.83
7.1.260.0060.00916.05
7.1.250.0000.00916.18
7.1.240.0030.01015.96
7.1.230.0030.00816.01
7.1.220.0070.00716.11
7.1.210.0000.00916.17
7.1.200.0020.01215.93
7.1.190.0000.01415.95
7.1.180.0040.00716.11
7.1.170.0030.00915.78
7.1.160.1910.01316.59
7.1.150.1820.01016.66
7.1.140.1680.00916.49
7.1.130.1590.01216.63
7.1.120.1840.01116.38
7.1.110.1510.01116.35
7.1.100.1860.01016.25
7.1.90.1500.01116.21
7.1.80.1500.01016.25
7.1.70.1670.00915.74
7.1.60.1510.01424.91
7.1.50.1990.01124.80
7.1.40.1740.01224.46
7.1.30.1480.01024.57
7.1.20.2500.01724.69
7.1.10.2310.00815.59
7.1.00.2180.01215.62
7.0.330.0040.00415.82
7.0.320.0060.00915.58
7.0.310.0030.01015.59
7.0.300.0110.00315.73
7.0.290.0000.01415.63
7.0.280.0090.00915.82
7.0.270.0130.00315.89
7.0.260.0040.01215.77
7.0.250.0040.01115.48
7.0.240.0000.01115.70
7.0.230.0080.00815.73
7.0.220.0060.00615.77
7.0.210.0040.00815.71
7.0.200.0000.01515.43
7.0.190.0070.00715.68
7.0.180.0040.01115.86
7.0.170.0000.01415.74
7.0.160.0060.00615.42
7.0.150.0060.00615.70
7.0.140.0110.00415.73
7.0.130.0060.00315.76
7.0.120.0000.01415.70
7.0.110.0000.01415.84
7.0.100.0120.00315.47
7.0.90.0060.00615.56
7.0.80.0040.00815.62
7.0.70.0030.01215.63
7.0.60.0030.01015.68
7.0.50.0030.01016.05
7.0.40.0070.00713.90
7.0.30.0060.00613.73
7.0.20.0090.00613.84
7.0.10.0000.01213.76
7.0.00.0000.01113.85
5.6.400.0000.01114.64
5.6.390.0040.00814.52
5.6.380.0090.00614.82
5.6.370.0090.00614.52
5.6.360.0030.01014.76
5.6.350.0040.00814.80
5.6.340.0090.00615.03
5.6.330.0030.01214.84
5.6.320.0070.00714.56
5.6.310.0030.01014.80
5.6.300.0060.00314.53
5.6.290.0040.01114.53
5.6.280.0090.00614.63
5.6.270.0140.00314.51
5.6.260.0110.00314.73
5.6.250.0060.00914.69
5.6.240.0030.01314.95
5.6.230.0080.00614.52
5.6.220.0030.01214.63
5.6.210.0030.01014.62
5.6.200.0070.01014.96
5.6.190.0030.00914.52
5.6.180.0100.00314.65
5.6.170.0000.01314.54
5.6.160.0090.00915.01
5.6.150.0060.00614.38
5.6.140.0160.00014.78
5.6.130.0030.00614.81
5.6.120.0000.01014.62
5.6.110.0000.01314.50
5.6.100.0030.01014.96
5.6.90.0040.00714.67
5.6.80.0100.00014.55
5.6.70.0030.01014.82
5.6.60.0000.01414.34
5.6.50.0070.00714.57
5.6.40.0070.00714.45
5.6.30.0000.00914.53
5.6.20.0070.00714.92
5.6.10.0000.01314.50
5.6.00.0030.00614.66

preferences:
29.06 ms | 403 KiB | 5 Q