3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<div id="x"><img src="/images/xyz" alt="xyz" /><p>hello world!</p></div>'; $doc = new DomDocument(); $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DomXPath($doc); $images = $xpath->query('//img'); foreach ($images as $img) { // create a new anchor element $a = $doc->createElement('a'); // copy the img src attribute to the a href attribute $a->setAttribute('href', $img->attributes->getNamedItem('src')->nodeValue); // add the a to the parent $img->parentNode->replaceChild($a, $img); // make the image a child of the <a> element $a->appendChild($img); } 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.3.70.0080.00818.80
8.3.60.0080.00818.53
8.3.50.0120.00618.84
8.3.40.0120.00619.27
8.3.30.0040.01119.09
8.3.20.0030.00719.35
8.3.10.0080.00022.29
8.3.00.0040.00421.25
8.2.190.0160.00316.92
8.2.180.0120.00316.75
8.2.170.0120.00319.16
8.2.160.0170.00322.96
8.2.150.0060.01224.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.27
8.2.110.0060.00321.56
8.2.100.0040.00818.09
8.2.90.0050.00318.28
8.2.80.0050.00317.88
8.2.70.0030.00618.00
8.2.60.0040.00418.28
8.2.50.0060.00318.07
8.2.40.0040.00418.41
8.2.30.0060.00318.36
8.2.20.0040.00418.32
8.2.10.0040.00418.46
8.2.00.0080.00018.40
8.1.280.0120.00325.92
8.1.270.0000.00823.99
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0080.00024.39
8.1.230.0100.00317.61
8.1.220.0060.00318.03
8.1.210.0040.00819.34
8.1.200.0000.01017.73
8.1.190.0040.00417.72
8.1.180.0060.00318.10
8.1.170.0060.00318.95
8.1.160.0040.00419.35
8.1.150.0040.00419.13
8.1.140.0020.00522.43
8.1.130.0000.00720.54
8.1.120.0000.00717.87
8.1.110.0060.00317.85
8.1.100.0000.00917.91
8.1.90.0040.00417.79
8.1.80.0040.00417.84
8.1.70.0040.00417.75
8.1.60.0080.00317.89
8.1.50.0080.00017.96
8.1.40.0060.00317.87
8.1.30.0030.00617.89
8.1.20.0000.00817.99
8.1.10.0000.00717.87
8.1.00.0070.00017.88
8.0.300.0040.00420.53
8.0.290.0000.00817.13
8.0.280.0000.00718.90
8.0.270.0070.00017.55
8.0.260.0030.00318.80
8.0.250.0000.00717.31
8.0.240.0000.00817.34
8.0.230.0050.00317.24
8.0.220.0050.00217.26
8.0.210.0040.00417.16
8.0.200.0060.00017.18
8.0.190.0050.00317.34
8.0.180.0040.00417.21
8.0.170.0000.01017.19
8.0.160.0040.00417.18
8.0.150.0040.00417.12
8.0.140.0020.00517.28
8.0.130.0030.00313.71
8.0.120.0090.00017.25
8.0.110.0040.00417.25
8.0.100.0000.00717.36
8.0.90.0040.00417.23
8.0.80.0110.01017.16
8.0.70.0030.00417.23
8.0.60.0040.00417.12
8.0.50.0070.00017.12
8.0.30.0150.00617.43
8.0.20.0110.00817.54
8.0.10.0000.00717.36
8.0.00.0060.01217.25
7.4.330.0050.00015.55
7.4.320.0050.00216.84
7.4.300.0030.00516.98
7.4.290.0000.00716.89
7.4.280.0040.00416.98
7.4.270.0070.00016.84
7.4.260.0000.00716.96
7.4.250.0000.00816.84
7.4.240.0000.00817.03
7.4.230.0000.00716.73
7.4.220.0050.00216.90
7.4.210.0050.01016.88
7.4.200.0000.00717.02
7.4.160.0110.00816.84
7.4.140.0120.00717.86
7.4.130.0090.00916.88
7.4.120.0110.00916.83
7.4.110.0070.01016.91
7.4.100.0110.01216.70
7.4.90.0060.01216.85
7.4.80.0110.01419.39
7.4.70.0070.01417.01
7.4.60.0040.01517.03
7.4.50.0030.00916.88
7.4.40.0030.01316.67
7.4.00.0050.01115.15
7.3.330.0030.00313.46
7.3.320.0050.00013.36
7.3.310.0040.00416.59
7.3.300.0030.00316.59
7.3.290.0030.00316.55
7.3.280.0110.00416.61
7.3.260.0130.00716.78
7.3.240.0100.01016.95
7.3.230.0030.01616.97
7.3.210.0140.00917.00
7.3.200.0090.01216.87
7.3.190.0140.00316.75
7.3.180.0030.01517.00
7.3.170.0100.01216.66
7.3.160.0160.00917.03
7.3.120.0100.01015.14
7.3.110.0070.01014.79
7.3.100.0070.01015.27
7.3.90.0070.00715.04
7.3.80.0070.00714.84
7.3.70.0040.01115.03
7.3.60.0030.00615.08
7.3.50.0110.00414.95
7.3.40.0080.00415.00
7.3.30.0070.00414.93
7.3.20.0070.01016.82
7.3.10.0060.00616.68
7.3.00.0070.00716.73
7.2.330.0120.00917.26
7.2.320.0090.01517.13
7.2.310.0070.01017.21
7.2.300.0100.00717.25
7.2.290.0180.00016.85
7.2.250.0100.01015.51
7.2.240.0100.01015.13
7.2.230.0030.01015.09
7.2.220.0000.01214.95
7.2.210.0150.00015.31
7.2.200.0030.01214.94
7.2.190.0060.00615.38
7.2.180.0100.00315.10
7.2.170.0070.00715.17
7.2.120.0150.00914.86
7.2.110.0210.00614.86
7.2.100.0230.01314.84
7.2.90.0380.00715.18
7.2.80.0480.01015.13
7.2.70.0350.00315.50
7.2.60.0360.00315.37
7.2.50.0190.01015.38
7.2.40.0240.00915.13
7.2.30.0400.01015.48
7.2.20.0410.00715.09
7.2.10.0220.00715.36
7.2.00.0240.00315.14
7.1.330.0070.00715.90
7.1.320.0000.01016.03
7.1.310.0030.01016.04
7.1.300.0060.00916.12
7.1.290.0100.00315.99
7.1.280.0060.00915.89
7.1.270.0030.00615.95
7.1.260.0030.01015.92
7.1.230.0270.00714.05
7.1.220.0200.01014.00
7.1.210.0230.00714.02
7.1.200.0310.00614.05
7.1.190.0300.00714.04
7.1.180.0280.00314.32
7.1.170.0300.00714.37
7.1.160.0150.01114.11
7.1.150.0160.01014.04
7.1.140.0260.00714.10
7.1.130.0260.00314.21
7.1.120.0190.01214.11
7.1.110.0170.01014.25
7.1.100.0210.00414.26
7.1.90.0230.01014.19
7.1.80.0300.00313.96
7.1.70.0230.00714.07
7.1.60.0250.01114.27
7.1.50.0260.00614.19
7.1.40.1240.00714.11
7.1.30.0470.00014.05
7.1.20.0190.00614.12
7.1.10.0220.01114.15
7.1.00.0810.00714.21
5.6.380.0110.00514.52

preferences:
18.27 ms | 401 KiB | 5 Q