3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML Meet God's General Kathryn Kuhlman. <br> <img class="lazy_responsive" title="Kathryn Kuhlman - iUseFaith.com" src="https://www.iusefaith.com/ojm_thumbnail/1000/32f808f79011a7c0bd1ffefc1365c856.jpg" alt="Kathryn Kuhlman - iUseFaith.com" width="1600" height="517" /> <br> Follow <a href="https://www.iusefaith.com/en-354" title="Kathryn Kuhlman">Kathryn Kuhlman</a> <br> Max KANTCHEDE & Kathryn Kuhlman HTML; $keywords = [ 'Kathryn Kuhlman' => 'https://www.example.com/en-354', 'Max KANTCHEDE' => 'https://www.example.com/MaxKANTCHEDE', 'eneral' => 'https://www.example.com/this-is-not-used', ]; libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); $lookup = []; $regexNeedles = []; foreach ($keywords as $name => $link) { $lookup[strtolower($name)] = $link; $regexNeedles[] = preg_quote($name, '~'); } $pattern = '~\b(' . implode('|', $regexNeedles) . ')\b~i' ; foreach($xpath->query('//*[not(self::img or self::a)]/text()') as $textNode) { $newNodes = []; $hasReplacement = false; foreach (preg_split($pattern, $textNode->nodeValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $fragment) { $fragmentLower = strtolower($fragment); if (isset($lookup[$fragmentLower])) { $hasReplacement = true; $a = $dom->createElement('a'); $a->setAttribute('href', $lookup[$fragmentLower]); $a->setAttribute('title', $fragment); $a->nodeValue = $fragment; $newNodes[] = $a; } else { $newNodes[] = $dom->createTextNode($fragment); } } if ($hasReplacement) { $newFragment = $dom->createDocumentFragment(); foreach ($newNodes as $newNode) { $newFragment->appendChild($newNode); } $textNode->parentNode->replaceChild($newFragment, $textNode); } } echo substr(trim($dom->saveHTML()), 3, -4);

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.140.0140.00718.23
8.4.130.0130.00719.16
8.4.120.0070.00421.09
8.4.110.0120.00920.95
8.4.100.0060.00419.20
8.4.90.0110.01019.34
8.4.80.0130.00718.38
8.4.70.0120.00520.08
8.4.60.0120.00920.08
8.4.50.0090.01022.89
8.4.40.0150.00619.97
8.4.30.0080.01220.67
8.4.20.0140.00718.64
8.4.10.0200.00021.18
8.3.270.0100.01216.98
8.3.260.0150.00517.28
8.3.250.0140.00619.05
8.3.240.0120.00817.30
8.3.230.0130.00717.34
8.3.220.0030.00519.28
8.3.210.0070.00117.39
8.3.200.0060.00719.54
8.3.190.0040.00417.86
8.3.180.0120.00817.80
8.3.170.0110.00719.59
8.3.160.0090.00917.55
8.3.150.0070.01317.96
8.3.140.0030.00619.04
8.3.130.0070.00319.02
8.3.120.0090.00021.13
8.3.110.0090.00020.94
8.3.100.0060.00324.06
8.3.90.0130.00326.77
8.3.80.0030.00717.38
8.3.70.0070.01517.13
8.3.60.0120.00317.38
8.3.50.0070.01024.76
8.3.40.0140.00720.82
8.3.30.0070.00719.34
8.3.20.0060.00324.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.290.0080.01121.04
8.2.280.0100.00917.48
8.2.270.0000.00717.66
8.2.260.0160.00320.55
8.2.250.0060.00319.24
8.2.240.0060.00319.49
8.2.230.0030.00622.58
8.2.220.0060.01337.54
8.2.210.0150.00426.77
8.2.200.0000.00917.25
8.2.190.0150.00717.00
8.2.180.0090.01225.92
8.2.170.0140.00719.76
8.2.160.0090.00622.96
8.2.150.0000.00825.66
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0000.00826.35
8.2.110.0050.00520.87
8.2.100.0120.00018.47
8.2.90.0030.00618.53
8.2.80.0000.00818.43
8.2.70.0040.00418.30
8.2.60.0040.00418.67
8.2.50.0040.00418.25
8.2.40.0040.00419.98
8.2.30.0000.00819.90
8.2.20.0040.00418.41
8.2.10.0040.00419.83
8.2.00.0000.00719.64
8.1.330.0090.01122.39
8.1.320.0140.00816.86
8.1.310.0120.00618.93
8.1.300.0060.00318.46
8.1.290.0030.00618.88
8.1.280.0060.00925.92
8.1.270.0040.00422.68
8.1.260.0000.00828.09
8.1.250.0000.00928.09
8.1.240.0090.00021.18
8.1.230.0090.00321.35
8.1.220.0050.00318.26
8.1.210.0080.00019.29
8.1.200.0030.00717.85
8.1.190.0050.00317.85
8.1.180.0030.00618.10
8.1.170.0030.00519.16
8.1.160.0030.00719.43
8.1.150.0050.00319.27
8.1.140.0000.00819.29
8.1.130.0040.00417.91
8.1.120.0040.00417.89
8.1.110.0000.00817.94
8.1.100.0000.00717.86
8.1.90.0000.00918.01
8.1.80.0030.00618.05
8.1.70.0000.00717.88
8.1.60.0000.00818.11
8.1.50.0090.00017.96
8.1.40.0030.00618.04
8.1.30.0030.00518.05
8.1.20.0050.00318.14
8.1.10.0030.00618.07
8.1.00.0040.00417.98
8.0.300.0000.00920.20
8.0.290.0030.00517.25
8.0.280.0000.00718.83
8.0.270.0070.00017.49
8.0.260.0070.00017.49
8.0.250.0030.00317.61
8.0.240.0030.00517.54
8.0.230.0040.00417.45
8.0.220.0040.00417.38
8.0.210.0000.00817.43
8.0.200.0040.00417.48
8.0.190.0000.00717.61
8.0.180.0000.00717.45
8.0.170.0030.00617.49
8.0.160.0080.00017.39
8.0.150.0030.00617.39
8.0.140.0000.00817.42
8.0.130.0070.00014.02
8.0.120.0020.00517.38
8.0.110.0050.00217.38
8.0.100.0000.00817.24
8.0.90.0030.00517.49
8.0.80.0000.01617.45
8.0.70.0070.00317.37
8.0.60.0040.00417.20
8.0.50.0050.00317.27
8.0.30.0130.01317.82
8.0.20.0130.00617.73
8.0.10.0070.00017.48
8.0.00.0160.00317.30
7.4.330.0030.00315.66
7.4.320.0040.00417.19
7.4.300.0050.00317.11
7.4.290.0000.00817.04
7.4.280.0050.00317.11
7.4.270.0070.00017.14
7.4.260.0000.01117.03
7.4.250.0030.00617.11
7.4.240.0000.00717.15
7.4.230.0030.00517.11
7.4.220.0040.00317.28
7.4.210.0080.00917.04
7.4.200.0000.00717.14
7.4.130.0080.01217.10
7.4.120.0060.01217.11
7.4.110.0150.00317.17
7.4.100.0110.00716.99
7.4.90.0140.00516.96
7.4.80.0100.00716.94
7.4.70.0060.01217.00
7.4.60.0110.01116.97
7.4.50.0110.00817.04
7.4.40.0100.00717.05
7.4.30.0060.01217.03
7.4.20.0100.00717.00
7.4.10.0110.00716.94
7.4.00.0120.00617.11
7.3.330.0040.00316.75
7.3.320.0030.00313.80
7.3.310.0030.00316.96
7.3.300.0040.00416.78
7.3.290.0060.01216.87
7.3.260.0060.01316.82
7.3.230.0070.01017.11
7.3.220.0000.01616.89
7.3.210.0070.01117.09
7.3.200.0090.00916.86
7.3.190.0120.00616.85
7.3.180.0120.00616.92
7.3.170.0070.01017.05
7.3.160.0140.00416.92
7.3.150.0070.01116.98
7.3.140.0100.00717.07
7.3.130.0090.00917.06
7.3.120.0110.01116.79
7.3.110.0090.01216.89
7.3.100.0140.00716.95
7.3.90.0080.00817.09
7.3.80.0090.00916.99
7.3.70.0100.00716.86
7.3.60.0100.00716.87
7.3.50.0140.00316.95
7.3.40.0030.01316.88
7.3.30.0140.01016.97
7.3.20.0070.01716.98
7.3.10.0060.01316.88
7.3.00.0120.00616.94
7.2.330.0060.01617.16
7.2.320.0100.00717.20
7.2.310.0090.00916.98
7.2.300.0110.00817.13
7.2.290.0090.00917.08
7.2.280.0100.00717.18
7.2.270.0060.01217.07
7.2.260.0120.00817.02
7.2.250.0130.01017.28
7.2.240.0110.01017.16
7.2.230.0140.00317.13
7.2.220.0070.01016.96
7.2.210.0060.01317.12
7.2.200.0100.01017.00
7.2.190.0090.01217.24
7.2.180.0040.01417.12
7.2.170.0100.01717.24
7.2.160.0110.01117.07
7.2.150.0070.01117.21
7.2.140.0100.01017.15
7.2.130.0150.00417.20
7.2.120.0150.00317.24
7.2.110.0060.01217.19
7.2.100.0110.00917.21
7.2.90.0100.01016.96
7.2.80.0070.01317.20
7.2.70.0150.00417.05
7.2.60.0110.00717.23
7.2.50.0120.01217.26
7.2.40.0070.01317.21
7.2.30.0110.00717.11
7.2.20.0070.01117.10
7.2.10.0130.00617.09
7.2.00.0290.00617.15

preferences:
85.23 ms | 403 KiB | 5 Q