3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = "<div><p><br/>Hello World</p><p><br/></p><p> <br> </p></div>"; $doc = new DOMDocument(); $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($doc); // find <br> within a <p> that has text content $breaks = $xpath->query("//p[normalize-space()!='']/br"); // and remove them foreach ($breaks as $br) { $br->parentNode->removeChild($br); } echo $doc->saveHTML(); $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($doc); // find <br> within a <p> that has text content $breaks = $xpath->query("//p[text()!='']/br"); // and remove them foreach ($breaks as $br) { $br->parentNode->removeChild($br); } echo $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.5.00.0160.00620.06
8.4.150.0020.00014.05
8.4.140.0130.00917.80
8.4.130.0110.00818.08
8.4.120.0110.01020.87
8.4.110.0120.00822.76
8.4.100.0130.00718.22
8.4.90.0050.00520.94
8.4.80.0090.00518.34
8.4.70.0120.00818.20
8.4.60.0100.01118.92
8.4.50.0100.00818.29
8.4.40.0090.00019.79
8.4.30.0070.01320.66
8.4.20.0150.00620.89
8.4.10.0100.00717.98
8.3.280.0110.01118.52
8.3.270.0110.01016.96
8.3.260.0100.00516.80
8.3.250.0120.00719.14
8.3.240.0090.01116.95
8.3.230.0090.00916.79
8.3.220.0130.00719.36
8.3.210.0130.00616.81
8.3.200.0140.00516.98
8.3.190.0110.01017.30
8.3.180.0070.01116.75
8.3.170.0040.00419.07
8.3.160.0070.01117.01
8.3.150.0060.01320.86
8.3.140.0070.00719.09
8.3.130.0030.00718.61
8.3.120.0110.00820.93
8.3.110.0060.00320.94
8.3.100.0080.00024.06
8.3.90.0040.00426.77
8.3.80.0060.00319.36
8.3.70.0150.00018.55
8.3.60.0060.01218.39
8.3.50.0110.00717.82
8.3.40.0080.00819.22
8.3.30.0040.01418.92
8.3.20.0040.00419.41
8.3.10.0030.00522.15
8.3.00.0050.00321.84
8.2.290.0050.00718.92
8.2.280.0120.00818.91
8.2.270.0140.00517.36
8.2.260.0100.01019.32
8.2.250.0000.00817.02
8.2.240.0050.00517.40
8.2.230.0030.00622.58
8.2.220.0040.00437.54
8.2.210.0040.00426.77
8.2.200.0050.00518.92
8.2.190.0180.00418.54
8.2.180.0060.01317.13
8.2.170.0090.00622.96
8.2.160.0000.01420.69
8.2.150.0070.00324.18
8.2.140.0000.00724.66
8.2.130.0000.00822.60
8.2.120.0030.00526.35
8.2.110.0130.01020.72
8.2.100.0120.00018.09
8.2.90.0050.00318.00
8.2.80.0050.00318.18
8.2.70.0030.00518.18
8.2.60.0090.00018.41
8.2.50.0000.00818.10
8.2.40.0090.00019.76
8.2.30.0040.00419.64
8.2.20.0100.00018.46
8.2.10.0090.00018.39
8.2.00.0040.00419.87
8.1.330.0070.00916.74
8.1.320.0140.00716.30
8.1.310.0110.00716.98
8.1.300.0060.00618.84
8.1.290.0030.00630.84
8.1.280.0110.00425.92
8.1.270.0030.00622.49
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0060.00324.24
8.1.230.0100.00719.38
8.1.220.0040.00417.93
8.1.210.0040.00421.23
8.1.200.0030.00717.60
8.1.190.0090.00017.60
8.1.180.0000.00818.10
8.1.170.0000.00818.87
8.1.160.0080.00319.23
8.1.150.0040.00419.17
8.1.140.0000.00822.38
8.1.130.0070.00320.43
8.1.120.0070.00017.83
8.1.110.0000.00817.82
8.1.100.0040.00417.82
8.1.90.0070.00017.82
8.1.80.0000.00817.75
8.1.70.0040.00417.72
8.1.60.0030.00617.82
8.1.50.0050.00317.91
8.1.40.0000.00817.79
8.1.30.0060.00317.97
8.1.20.0060.00317.93
8.1.10.0000.00817.88
8.1.00.0040.00417.84
8.0.300.0040.00419.93
8.0.290.0060.00317.13
8.0.280.0030.00318.83
8.0.270.0040.00417.51
8.0.260.0000.00718.74
8.0.250.0040.00417.29
8.0.240.0000.00717.25
8.0.230.0050.00317.19
8.0.220.0070.00017.17
8.0.210.0000.00817.23
8.0.200.0070.00317.31
8.0.190.0040.00417.24
8.0.180.0040.00417.22
8.0.170.0040.00417.29
8.0.160.0040.00417.29
8.0.150.0030.00317.21
8.0.140.0050.00217.15
8.0.130.0000.00613.66
8.0.120.0040.00417.12
8.0.110.0000.00717.25
8.0.100.0000.00817.09
8.0.90.0040.00417.16
8.0.80.0070.01017.10
8.0.70.0040.00416.97
8.0.60.0030.00517.18
8.0.50.0040.00417.25
8.0.30.0080.01017.38
8.0.20.0110.00817.51
8.0.10.0050.00217.34
8.0.00.0190.01017.12
7.4.330.0000.00517.04
7.4.320.0000.00616.75
7.4.300.0000.00716.91
7.4.290.0040.00416.77
7.4.280.0050.00316.86
7.4.270.0080.00016.76
7.4.260.0000.00816.81
7.4.250.0050.00316.81
7.4.240.0040.00416.84
7.4.230.0000.00716.94
7.4.220.0040.00416.93
7.4.210.0040.01016.85
7.4.200.0000.00816.94
7.4.160.0100.00716.86
7.4.140.0080.01217.86
7.4.130.0080.00817.00
7.4.120.0110.01316.84
7.4.110.0120.00616.83
7.4.100.0070.01016.96
7.4.90.0070.01016.67
7.4.80.0110.01119.39
7.4.70.0080.00816.80
7.4.60.0110.00616.84
7.4.50.0040.01116.75
7.4.40.0110.00716.74
7.4.00.0060.00914.93
7.3.330.0030.00313.47
7.3.320.0060.00013.32
7.3.310.0070.00016.54
7.3.300.0000.00616.67
7.3.290.0000.00716.61
7.3.280.0100.01016.62
7.3.260.0110.00716.77
7.3.240.0110.00816.83
7.3.230.0070.01416.58
7.3.210.0130.00616.53
7.3.200.0150.00616.84
7.3.190.0130.00616.73
7.3.180.0040.01216.92
7.3.170.0130.00316.61
7.3.160.0110.01116.78
7.2.330.0070.01016.95
7.2.320.0120.01216.87
7.2.310.0100.01316.76
7.2.300.0030.02016.90
7.2.290.0060.01116.75
7.2.120.0090.00614.86
7.2.110.0130.01015.03
7.2.100.0130.00514.64
7.2.90.0680.00314.59
7.2.80.1350.00314.46
7.2.70.1120.00715.20
7.2.60.1350.00314.99
7.2.50.1800.01014.96
7.2.40.1450.00314.86
7.2.30.1150.00715.05
7.2.20.1670.00014.98
7.2.10.2140.00915.08
7.2.00.1580.01315.39
7.1.240.0810.00913.84
7.1.230.0570.00413.73
7.1.220.2020.01014.24
7.1.210.0130.00314.08
7.1.200.0190.01313.99
7.1.190.1960.01014.08
7.1.180.1210.00713.94
7.1.170.1780.01013.94
7.1.160.1550.00713.72
7.1.150.1930.01013.80
7.1.140.1510.01013.90
7.1.130.2110.00713.97
7.1.120.2600.00614.06
7.1.110.2920.01013.93
7.1.100.2100.01313.82
7.1.90.1690.00313.84
7.1.80.1950.00713.84
7.1.70.2560.01013.97
7.1.60.1580.01013.81
7.1.50.1280.01213.87
7.1.40.2730.01313.99
7.1.30.0950.01013.73
7.1.20.1140.00714.00
7.1.10.1370.01314.08
7.1.00.1860.00214.13
5.6.380.0110.00513.96

preferences:
39.76 ms | 403 KiB | 5 Q