3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOD <p>С этой формы приходят заявки <a href="https://site.com/lack_tech.php">https://site.com/lack_tech.php</a></p> <p>Или что ты имеешь ввиду?</p> <div class="attachment_files_message"> <p>Прикреплённые файлы:</p> <a href="http://site.com/public/uploads/kylticket/2670/Screenshot_1.png" target="_blank">Screenshot_1.png</a> </div> EOD; $dom = new DOMDocument(); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query('//a[@target="_blank"]') as $OurNode) { if (preg_match('~\.(?:jpe?g|png)$~i', $OurNode->getAttribute('href'))) { $fragment = $dom->createDocumentFragment(); $aNode = $dom->createElement('a'); $aNode->setAttribute('data-fancybox', 'gallery'); // + data-fancybox $aNode->nodeValue = ''; $aNode->setAttribute('href', $OurNode->getAttribute('href')); $img = $dom->createElement('img'); $img->setAttribute("src", $OurNode->getAttribute('href')); $img->setAttribute("alt", ""); $img->setAttribute("class", "tmp_class"); $aNode->appendChild($img); $fragment->appendChild($aNode); $OurNode->parentNode->replaceChild($fragment, $OurNode); } } echo mb_convert_encoding($dom->saveHTML(), 'UTF-8', 'HTML-ENTITIES');

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.120.0120.00822.72
8.4.110.0120.01019.47
8.4.100.0150.00619.36
8.4.90.0110.01019.32
8.4.80.0130.00820.80
8.4.70.0140.00718.66
8.4.60.0050.00619.07
8.4.50.0170.00620.41
8.4.40.0120.00018.45
8.4.30.0100.01120.00
8.4.20.0100.01018.53
8.4.10.0100.00718.43
8.3.250.0110.00819.72
8.3.240.0120.00817.33
8.3.230.0100.00819.54
8.3.220.0040.00421.48
8.3.210.0060.00217.32
8.3.200.0050.00517.34
8.3.190.0070.00317.79
8.3.180.0040.00817.25
8.3.170.0030.01619.26
8.3.160.0060.01019.11
8.3.150.0070.01119.32
8.3.140.0060.00319.05
8.3.130.0100.00719.29
8.3.120.0150.00320.88
8.3.110.0050.00520.94
8.3.100.0130.00319.28
8.3.90.0060.00319.19
8.3.80.0040.00818.93
8.3.70.0150.00617.25
8.3.60.0140.00419.31
8.3.50.0080.00818.84
8.3.40.0040.01119.42
8.3.30.0110.00419.47
8.3.20.0040.00419.78
8.3.10.0110.00021.26
8.3.00.0050.00324.16
8.2.290.0090.00920.79
8.2.280.0050.00419.02
8.2.270.0110.00717.72
8.2.260.0050.00317.25
8.2.250.0140.00717.00
8.2.240.0030.00617.46
8.2.230.0060.00322.58
8.2.220.0040.00424.06
8.2.210.0080.00026.77
8.2.200.0090.00019.04
8.2.190.0040.01319.13
8.2.180.0070.01117.38
8.2.170.0120.00919.58
8.2.160.0100.00722.96
8.2.150.0050.00524.18
8.2.140.0030.00524.66
8.2.130.0120.00020.32
8.2.120.0000.00826.35
8.2.110.0060.00322.58
8.2.100.0120.00318.43
8.2.90.0030.00618.38
8.2.80.0030.00519.36
8.2.70.0090.00018.53
8.2.60.0000.00818.72
8.2.50.0040.00418.13
8.2.40.0050.00319.71
8.2.30.0040.00419.77
8.2.20.0080.00018.42
8.2.10.0000.00818.59
8.2.00.0070.00019.92
8.1.330.0110.01022.57
8.1.320.0100.01018.55
8.1.310.0030.01417.36
8.1.300.0100.00018.98
8.1.290.0030.00718.88
8.1.280.0030.01325.92
8.1.270.0040.00422.48
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00324.10
8.1.230.0140.00021.31
8.1.220.0050.00318.15
8.1.210.0040.00418.77
8.1.200.0040.00417.98
8.1.190.0090.00317.85
8.1.180.0030.00618.13
8.1.170.0040.00419.26
8.1.160.0040.00419.32
8.1.150.0000.00719.41
8.1.140.0040.00418.10
8.1.130.0030.00319.51
8.1.120.0000.01018.04
8.1.110.0100.00018.00
8.1.100.0040.00418.08
8.1.90.0040.00717.99
8.1.80.0060.00318.06
8.1.70.0040.00418.07
8.1.60.0080.00018.22
8.1.50.0070.00318.16
8.1.40.0030.00518.15
8.1.30.0040.00418.23
8.1.20.0000.00918.19
8.1.10.0030.00518.11
8.1.00.0000.00818.20
8.0.300.0030.00518.77
8.0.290.0060.00317.25
8.0.280.0000.00718.80
8.0.270.0000.00917.54
8.0.260.0060.00317.82
8.0.250.0060.00317.62
8.0.240.0000.00717.67
8.0.230.0000.00817.65
8.0.220.0050.00217.55
8.0.210.0000.00717.50
8.0.200.0030.00517.55
8.0.190.0000.00817.60
8.0.180.0080.00017.58
8.0.170.0000.00817.58
8.0.160.0050.00317.48
8.0.150.0080.00017.56
8.0.140.0080.00017.54
8.0.130.0000.00614.00
8.0.120.0040.00417.48
8.0.110.0050.00217.37
8.0.100.0000.00817.53
8.0.90.0040.00417.52
8.0.80.0070.01117.59
8.0.70.0030.00517.49
8.0.60.0000.00917.68
8.0.50.0000.00717.41
8.0.30.0070.01117.72
8.0.20.0120.01017.66
8.0.10.0000.00717.51
8.0.00.0120.00617.44
7.4.330.0030.00315.55
7.4.320.0000.00717.25
7.4.300.0030.00317.25
7.4.290.0000.00717.16
7.4.280.0000.00717.23
7.4.270.0060.00317.27
7.4.260.0000.00817.29
7.4.250.0040.00417.18
7.4.240.0040.00417.15
7.4.230.0070.00017.25
7.4.220.0050.00317.35
7.4.210.0090.01017.35
7.4.200.0050.00317.28
7.4.160.0060.01117.23
7.4.140.0100.00817.86
7.4.130.0090.00817.04
7.4.120.0110.01017.20
7.4.110.0150.00917.19
7.4.100.0120.00617.25
7.4.90.0100.01317.04
7.4.80.0190.00619.39
7.4.70.0090.01317.21
7.4.60.0040.01217.00
7.4.50.0130.00317.04
7.4.40.0070.01417.20
7.4.00.0060.00915.10
7.3.330.0060.00013.85
7.3.320.0000.00613.78
7.3.310.0070.00016.95
7.3.300.0000.00816.93
7.3.290.0050.00316.86
7.3.280.0080.01016.90
7.3.260.0110.00917.01
7.3.240.0080.01017.05
7.3.230.0100.00716.98
7.3.210.0000.01916.89
7.3.200.0030.01317.15
7.3.190.0040.01417.04
7.3.180.0100.00717.15
7.3.170.0110.01017.08
7.3.160.0060.01016.79
7.3.120.0100.01015.18
7.3.110.0070.01115.22
7.3.100.0140.00315.32
7.3.90.0000.01015.04
7.3.80.0060.00915.02
7.3.70.0000.01414.96
7.3.60.0100.00315.06
7.3.50.0030.00615.23
7.3.40.0110.00015.12
7.3.30.0040.00815.16
7.3.20.0070.01017.09
7.3.10.0040.00816.86
7.3.00.0030.00717.00
7.2.330.0170.00417.32
7.2.320.0140.00717.21
7.2.310.0080.01117.31
7.2.300.0100.00717.35
7.2.290.0140.00617.46
7.2.250.0070.01015.59
7.2.240.0040.01815.56
7.2.230.0060.00815.27
7.2.220.0030.01015.59
7.2.210.0060.00615.25
7.2.200.0090.00615.51
7.2.190.0000.01715.34
7.2.180.0090.00615.40
7.2.170.0040.00715.32
7.2.60.0180.01815.41
7.2.50.0180.00715.62
7.2.40.0180.00715.57
7.2.30.0240.00315.39
7.2.20.0320.00715.53
7.2.10.0240.01215.48
7.2.00.0130.01615.53
7.1.330.0100.00316.00
7.1.320.0070.00716.16
7.1.310.0070.00316.29
7.1.300.0060.00616.08
7.1.290.0070.01016.39
7.1.280.0060.00916.24
7.1.270.0040.00816.04
7.1.260.0040.00415.98
7.1.200.0060.01016.10
7.1.170.0210.00714.03
7.1.160.0190.01014.37
7.1.150.0270.00614.18
7.1.140.0200.01314.34
7.1.130.0870.00714.32
7.1.120.0160.00914.29
7.1.110.0220.00414.35
7.1.100.0150.00914.05
7.1.90.0260.01314.09
7.1.80.0250.01114.26
7.1.70.0240.01214.37
7.1.60.0540.01031.99
7.1.50.0460.01331.95
7.1.40.0390.01631.76
7.1.30.0690.01031.85
7.1.20.0440.02831.95
7.1.10.0240.00914.40
7.1.00.0230.00814.39

preferences:
29.97 ms | 403 KiB | 5 Q