3v4l.org

run code in 500+ 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 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.5.90.0050.00317.42
8.5.80.0080.00717.49
8.5.70.0080.00517.45
8.5.60.0070.00618.21
8.5.50.0070.00418.14
8.5.40.0090.00217.13
8.5.30.0110.00417.53
8.5.20.0080.00519.77
8.5.10.0120.00517.14
8.5.00.0080.00719.86
8.4.240.0090.00920.18
8.4.230.0080.01020.19
8.4.220.0080.00520.06
8.4.210.0100.00721.06
8.4.200.0080.00721.85
8.4.190.0060.00620.34
8.4.180.0110.00820.34
8.4.170.0100.00821.16
8.4.160.0120.00621.14
8.4.150.0070.00618.90
8.4.140.0120.00619.12
8.4.130.0100.00619.68
8.4.120.0120.00421.55
8.4.110.0090.00719.68
8.4.100.0090.00819.12
8.4.90.0090.00720.52
8.4.80.0080.00720.54
8.4.70.0090.00819.75
8.4.60.0110.00619.79
8.4.50.0110.00820.52
8.4.40.0170.00219.27
8.4.30.0100.00919.47
8.4.20.0140.00918.16
8.4.10.0150.00519.65
8.3.330.0110.00818.90
8.3.320.0070.00819.91
8.3.310.0070.00418.86
8.3.300.0090.00720.06
8.3.290.0080.01020.95
8.3.280.0110.00619.82
8.3.270.0080.00717.96
8.3.260.0090.00717.98
8.3.250.0080.00818.26
8.3.240.0080.01117.12
8.3.230.0080.00517.99
8.3.220.0050.00419.27
8.3.210.0100.00617.85
8.3.200.0080.00518.08
8.3.190.0070.00818.19
8.3.180.0090.00619.15
8.3.170.0060.01018.89
8.3.160.0080.00718.19
8.3.150.0090.00618.29
8.3.140.0070.00718.23
8.3.130.0060.00418.76
8.3.120.0090.00119.89
8.3.110.0050.00419.03
8.3.100.0050.00420.60
8.3.90.0070.00622.86
8.3.80.0070.00318.04
8.3.70.0070.00517.10
8.3.60.0070.00818.13
8.3.50.0080.00722.88
8.3.40.0110.00520.51
8.3.30.0070.00519.75
8.3.20.0070.00322.23
8.3.10.0120.00221.54
8.3.00.0060.00523.24
8.2.330.0050.00820.38
8.2.320.0080.00718.54
8.2.310.0100.00619.46
8.2.300.0120.00819.50
8.2.290.0100.00417.27
8.2.280.0130.00718.81
8.2.270.0150.00517.40
8.2.260.0120.00517.38
8.2.250.0100.00418.00
8.2.240.0110.00318.26
8.2.230.0100.00419.80
8.2.220.0120.00227.25
8.2.210.0140.00421.87
8.2.200.0100.00317.28
8.2.190.0130.00817.08
8.2.180.0110.00921.46
8.2.170.0150.00619.09
8.2.160.0080.01020.69
8.2.150.0090.00421.97
8.2.140.0090.00421.57
8.2.130.0090.00922.28
8.2.120.0110.00819.83
8.2.110.0140.00619.55
8.2.100.0150.00618.27
8.2.90.0120.00518.39
8.2.80.0110.00818.20
8.2.70.0080.00518.50
8.2.60.0070.00318.35
8.2.50.0110.00418.25
8.2.40.0090.00518.59
8.2.30.0100.00318.35
8.2.20.0090.00518.27
8.2.10.0080.00418.96
8.2.00.0110.00319.06
8.1.340.0160.00619.31
8.1.330.0160.00616.71
8.1.320.0140.00617.58
8.1.310.0140.00717.72
8.1.300.0070.00618.40
8.1.290.0120.00317.83
8.1.280.0120.00821.26
8.1.270.0090.00421.22
8.1.260.0090.00422.31
8.1.250.0070.00423.16
8.1.240.0110.00420.26
8.1.230.0080.00420.21
8.1.220.0090.00618.17
8.1.210.0080.00518.53
8.1.200.0060.00517.97
8.1.190.0090.00317.85
8.1.180.0080.00318.12
8.1.170.0070.00418.65
8.1.160.0050.00618.59
8.1.150.0070.00418.59
8.1.140.0090.00319.54
8.1.130.0070.00419.32
8.1.120.0080.00218.10
8.1.110.0070.00417.92
8.1.100.0060.00418.12
8.1.90.0050.00618.04
8.1.80.0040.00618.08
8.1.70.0050.00518.08
8.1.60.0060.00418.21
8.1.50.0070.01018.07
8.1.40.0090.00518.12
8.1.30.0070.00618.11
8.1.20.0060.00618.19
8.1.10.0120.00617.95
8.1.00.0110.00618.04
8.0.300.0080.00819.71
8.0.290.0080.00617.48
8.0.280.0040.00618.21
8.0.270.0080.00417.89
8.0.260.0090.00418.94
8.0.250.0050.00517.51
8.0.240.0040.00417.50
8.0.230.0050.00517.53
8.0.220.0080.00617.51
8.0.210.0160.00617.38
8.0.200.0140.00517.41
8.0.190.0130.00617.39
8.0.180.0150.00717.44
8.0.170.0090.00817.44
8.0.160.0110.00717.57
8.0.150.0090.00417.40
8.0.140.0130.00717.45
8.0.130.0140.00415.62
8.0.120.0050.00417.28
8.0.110.0040.00617.42
8.0.100.0080.00217.52
8.0.90.0060.00517.38
8.0.80.0080.00818.08
8.0.70.0040.00517.49
8.0.60.0050.00417.50
8.0.50.0050.00517.46
8.0.30.0060.01317.54
8.0.20.0110.00617.58
8.0.10.0060.00418.30
8.0.00.0120.00617.56
7.4.330.0080.00516.44
7.4.320.0060.00318.02
7.4.300.0030.00617.12
7.4.290.0060.00317.12
7.4.280.0080.00317.18
7.4.270.0030.00618.00
7.4.260.0050.00318.04
7.4.250.0060.00318.00
7.4.240.0040.00518.04
7.4.230.0070.00218.06
7.4.220.0060.00317.01
7.4.210.0090.00517.64
7.4.200.0050.00417.96
7.4.190.0060.00319.09
7.4.180.0080.00318.75
7.4.160.0100.00416.97
7.4.150.0060.00517.04
7.4.140.0070.00317.14
7.4.130.0110.00917.63
7.4.120.0100.00417.17
7.4.110.0090.00817.99
7.4.100.0070.00617.30
7.4.90.0070.00817.13
7.4.80.0100.00417.90
7.4.70.0070.00617.97
7.4.60.0080.00517.09
7.4.50.0100.00317.93
7.4.40.0070.00617.98
7.4.30.0090.00717.17
7.4.20.0080.00717.92
7.4.10.0120.00517.91
7.4.00.0100.00517.01
7.3.330.0100.00517.90
7.3.320.0020.00516.35
7.3.310.0030.00417.05
7.3.300.0040.00417.85
7.3.290.0080.00817.42
7.3.280.0070.00217.11
7.3.270.0050.00418.94
7.3.260.0080.00618.02
7.3.250.0080.00617.19
7.3.240.0040.00518.91
7.3.230.0070.00817.86
7.3.220.0070.00617.02
7.3.210.0070.00617.94
7.3.200.0110.00216.96
7.3.190.0070.00517.93
7.3.180.0080.00517.91
7.3.170.0080.00517.82
7.3.160.0080.00717.94
7.3.150.0120.00517.93
7.3.140.0060.00816.95
7.3.130.0070.00816.97
7.3.120.0050.01017.86
7.3.110.0070.00617.85
7.3.100.0070.00617.78
7.3.90.0070.00718.07
7.3.80.0100.00317.80
7.3.70.0100.00516.98
7.3.60.0060.00717.94
7.3.50.0080.00717.86
7.3.40.0090.00316.95
7.3.30.0110.00517.07
7.3.20.0090.00717.91
7.3.10.0060.01017.78
7.3.00.0070.00617.94
7.2.340.0060.00317.30
7.2.330.0110.00517.18
7.2.320.0050.01117.19
7.2.310.0090.00818.09
7.2.300.0050.01117.17
7.2.290.0120.00818.03
7.2.280.0100.00817.04
7.2.270.0120.00717.16
7.2.260.0140.00417.00
7.2.250.0080.00817.16
7.2.240.0120.00517.17
7.2.230.0130.00717.05
7.2.220.0120.00817.12
7.2.210.0100.00716.99
7.2.200.0130.00717.17
7.2.190.0090.01017.13
7.2.180.0090.00817.15
7.2.170.0110.00717.27
7.2.160.0120.00717.12
7.2.150.0150.00818.02
7.2.140.0150.00918.10
7.2.130.0110.00718.14
7.2.120.0130.00318.14
7.2.110.0070.01018.14
7.2.100.0170.00318.20
7.2.90.0120.00817.99
7.2.80.0140.00718.11
7.2.70.0140.00718.16
7.2.60.0120.00918.10
7.2.50.0160.00718.05
7.2.40.0090.00718.16
7.2.30.0120.00918.09
7.2.20.0070.01017.94
7.2.10.0030.01218.10
7.2.00.0100.00518.23

preferences:
114.6 ms | 1749 KiB | 5 Q