3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<div id="one-id" class="someClassName">Some text <a href="#" title="Words" id="linkId" class="classLink">link</a> with only the class and id attrtibutes.</div>'; $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query('//*') as $node) { for ($i = $node->attributes->length - 1; $i >= 0; --$i) { $attr = $node->attributes->item($i); if (!in_array($attr->name, ['id', 'class'])) { $node->removeAttribute($attr->name); } } } 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.5.00.0120.00920.19
8.4.150.0000.00214.05
8.4.140.0100.01118.04
8.4.130.0070.00918.02
8.4.120.0060.00324.40
8.4.110.0110.00922.17
8.4.100.0110.00718.33
8.4.90.0130.00819.03
8.4.80.0050.00319.95
8.4.70.0160.00518.20
8.4.60.0100.00624.32
8.4.50.0110.00919.19
8.4.40.0070.01419.28
8.4.30.0110.00820.88
8.4.20.0140.00718.37
8.4.10.0060.00319.79
8.3.280.0130.00819.00
8.3.270.0120.00916.86
8.3.260.0120.00117.49
8.3.250.0170.00219.31
8.3.240.0090.01017.41
8.3.230.0110.00816.95
8.3.220.0030.00517.69
8.3.210.0100.00718.92
8.3.200.0050.01017.03
8.3.190.0130.00717.55
8.3.180.0110.00717.68
8.3.170.0060.00921.10
8.3.160.0070.00717.56
8.3.150.0090.00917.55
8.3.140.0110.00716.83
8.3.130.0100.00018.84
8.3.120.0030.00620.98
8.3.110.0000.01020.94
8.3.100.0030.00618.68
8.3.90.0150.00026.77
8.3.80.0040.00418.55
8.3.70.0110.00417.13
8.3.60.0190.00018.93
8.3.50.0110.00716.95
8.3.40.0110.00322.46
8.3.30.0140.00322.32
8.3.20.0000.00724.18
8.3.10.0050.00324.66
8.3.00.0080.00026.16
8.2.290.0130.00620.56
8.2.280.0120.00718.91
8.2.270.0090.00917.54
8.2.260.0070.01117.03
8.2.250.0030.00517.24
8.2.240.0120.00817.54
8.2.230.0000.01622.58
8.2.220.0080.00024.06
8.2.210.0120.00326.77
8.2.200.0060.00318.91
8.2.190.0090.00617.00
8.2.180.0160.00625.92
8.2.170.0150.00622.96
8.2.160.0070.01022.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0040.00420.05
8.2.110.0140.00720.89
8.2.100.0140.00719.35
8.2.90.0240.00719.21
8.2.80.0190.00318.72
8.2.70.0320.00619.07
8.2.60.0230.01618.99
8.2.50.0190.00619.08
8.2.40.0050.00919.22
8.2.30.0060.00619.07
8.2.20.0140.00019.02
8.2.10.0080.01219.58
8.2.00.0140.00019.58
8.1.330.0140.00522.25
8.1.320.0150.00416.62
8.1.310.0040.00417.04
8.1.300.0110.00719.13
8.1.290.0040.00430.84
8.1.280.0040.01525.92
8.1.270.0000.01424.66
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0000.01319.00
8.1.230.0040.01118.95
8.1.220.0100.00319.00
8.1.210.0080.00820.25
8.1.200.0130.00018.89
8.1.190.0200.00718.85
8.1.180.0170.01418.57
8.1.170.0250.00418.83
8.1.160.0130.00019.10
8.1.150.0030.00920.96
8.1.140.0100.00318.92
8.1.130.0130.00018.86
8.1.120.0140.00018.98
8.1.110.0200.00318.57
8.1.100.0100.00318.93
8.1.90.0130.00018.95
8.1.80.0100.00318.97
8.1.70.0180.01219.13
8.1.60.0100.00619.24
8.1.50.0120.00419.00
8.1.40.0080.00819.05
8.1.30.0030.00919.29
8.1.20.0180.00419.09
8.1.10.0220.00319.13
8.1.00.0170.00719.04
8.0.300.0130.00317.83
8.0.290.0110.00418.15
8.0.280.0130.00018.21
8.0.270.0080.00618.15
8.0.260.0090.00618.02
8.0.250.0110.00418.01
8.0.240.0170.00018.31
8.0.230.0080.00818.52
8.0.220.0110.00718.16
8.0.210.0110.00318.14
8.0.200.0120.00318.25
8.0.190.0160.00018.25
8.0.180.0110.00418.18
8.0.170.0110.00018.20
8.0.160.0130.00318.25
8.0.150.0110.00418.29
8.0.140.0060.00817.96
8.0.130.0120.00018.54
8.0.120.0110.00318.11
8.0.110.0080.00618.13
8.0.100.0110.00418.26
8.0.90.0110.00418.08
8.0.80.0110.00418.00
8.0.70.0140.00018.12
8.0.60.0150.00018.12
8.0.50.0100.00518.11
8.0.30.0270.00718.11
8.0.20.0180.00918.19
8.0.10.0330.00318.22

preferences:
28.85 ms | 403 KiB | 5 Q