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); foreach ($dom->getElementsByTagName('*') 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.10.0090.01016.85
8.5.00.0150.00720.31
8.4.150.0020.00114.05
8.4.140.0160.00617.74
8.4.130.0070.00717.93
8.4.120.0140.00424.29
8.4.110.0050.00421.52
8.4.100.0120.00917.96
8.4.90.0130.00719.02
8.4.80.0110.01019.82
8.4.70.0060.00317.70
8.4.60.0130.00819.00
8.4.50.0080.00622.41
8.4.40.0140.00718.69
8.4.30.0090.00620.66
8.4.20.0130.00617.95
8.4.10.0030.00619.58
8.3.280.0150.00718.82
8.3.270.0130.01017.15
8.3.260.0110.00817.18
8.3.250.0070.00718.91
8.3.240.0090.01017.56
8.3.230.0050.00317.08
8.3.220.0120.00717.74
8.3.210.0110.00818.51
8.3.200.0080.00116.69
8.3.190.0120.00816.79
8.3.180.0130.00716.78
8.3.170.0140.00419.46
8.3.160.0000.00718.78
8.3.150.0110.00720.96
8.3.140.0150.00417.06
8.3.130.0110.00016.54
8.3.120.0060.00319.13
8.3.110.0030.00620.94
8.3.100.0000.00824.06
8.3.90.0200.00026.77
8.3.80.0090.00017.97
8.3.70.0160.00316.74
8.3.60.0060.01318.63
8.3.50.0110.01116.84
8.3.40.0030.01022.21
8.3.30.0080.00622.02
8.3.20.0050.00324.18
8.3.10.0000.00824.66
8.3.00.0000.00826.16
8.2.290.0110.00720.59
8.2.280.0100.00818.97
8.2.270.0200.00017.33
8.2.260.0070.01118.83
8.2.250.0040.00416.90
8.2.240.0040.00417.75
8.2.230.0060.00322.58
8.2.220.0090.00437.54
8.2.210.0090.00026.77
8.2.200.0000.01217.13
8.2.190.0060.00916.88
8.2.180.0040.01116.63
8.2.170.0160.00019.22
8.2.160.0060.01222.96
8.2.150.0040.00425.66
8.2.140.0050.00324.66
8.2.130.0000.00726.16
8.2.120.0040.00419.78
8.2.110.0060.00620.72
8.2.100.0150.00319.18
8.2.90.0150.00019.14
8.2.80.0090.00418.84
8.2.70.0160.00019.15
8.2.60.0140.00018.96
8.2.50.0050.01118.64
8.2.40.0110.00518.93
8.2.30.0080.00519.13
8.2.20.0090.00618.91
8.2.10.0080.00819.41
8.2.00.0160.00019.41
8.1.330.0120.00822.26
8.1.320.0090.01116.67
8.1.310.0000.00817.14
8.1.300.0100.00716.63
8.1.290.0060.00330.84
8.1.280.0040.01825.92
8.1.270.0040.00424.08
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0140.00018.82
8.1.230.0120.00318.85
8.1.220.0120.00418.70
8.1.210.0160.00019.89
8.1.200.0110.00418.94
8.1.190.0070.00718.68
8.1.180.0160.00018.64
8.1.170.0110.00418.86
8.1.160.0110.00518.64
8.1.150.0100.00320.79
8.1.140.0100.00618.58
8.1.130.0100.00518.93
8.1.120.0050.00818.80
8.1.110.0100.00218.96
8.1.100.0110.00618.86
8.1.90.0120.00318.65
8.1.80.0080.00518.73
8.1.70.0120.00318.92
8.1.60.0090.00918.77
8.1.50.0100.00818.91
8.1.40.0160.00018.93
8.1.30.0080.00519.38
8.1.20.0180.00018.81
8.1.10.0120.00418.89
8.1.00.0130.00318.86
8.0.300.0090.00917.93
8.0.290.0130.00618.11
8.0.280.0060.00818.20
8.0.270.0140.00317.96
8.0.260.0150.00317.65
8.0.250.0170.00018.05
8.0.240.0150.00318.10
8.0.230.0050.01118.63
8.0.220.0130.00317.86
8.0.210.0090.00918.32
8.0.200.0160.00017.86
8.0.190.0130.00518.26
8.0.180.0100.00518.17
8.0.170.0090.00618.16
8.0.160.0100.01018.08
8.0.150.0110.00818.14
8.0.140.0170.00017.93
8.0.130.0070.00718.58
8.0.120.0100.00718.14
8.0.110.0160.00018.01
8.0.100.0140.00418.19
8.0.90.0170.00017.88
8.0.80.0060.00917.88
8.0.70.0160.00018.21
8.0.60.0100.00717.90
8.0.50.0110.00418.14
8.0.30.0100.00718.00
8.0.20.0100.00718.15
8.0.10.0140.00318.12

preferences:
85.32 ms | 403 KiB | 5 Q