3v4l.org

run code in 300+ PHP versions simultaneously
<?php $HTML_string = ' <h1>Test of h1</h1> <p>This is a p test.</p> <h2>Test of h2</h2> <p>This is a p test with a <strong>strong emphasis</strong> followed by this.</p> <h3>Test of h3</h3> <p>This here is a link: <a href="http://www.example.com/1">Example.com</a>.<br> And this is a linebreak.</p> <p>Another paragraph, followed by a horizontal line:</p> <hr> <p>A final paragraph with <a href="http://www.example.com/2"><em>some emphasis</em> inside a link</a>.</p> '; function convertHTag(DOMNode $node) { $textNode = $node->ownerDocument->createTextNode(strtoupper($node->nodeName). ': ' . trim($node->textContent)); $node->ownerDocument->importNode($textNode); $node->parentNode->replaceChild($textNode, $node); } function convertATag(DOMNode $node) { $textNode = $node->ownerDocument->createTextNode(trim($node->textContent) . ' ( ' . $node->getAttribute('href') . ' ) '); $node->ownerDocument->importNode($textNode); $node->parentNode->replaceChild($textNode, $node); } function convertStrongTag(DOMNode $node) { $textNode = $node->ownerDocument->createTextNode(' **' . trim($node->textContent) . '** '); $node->ownerDocument->importNode($textNode); $node->parentNode->replaceChild($textNode, $node); } function convertEmTag(DOMNode $node) { $textNode = $node->ownerDocument->createTextNode(' *' . trim($node->textContent) . '* '); $node->ownerDocument->importNode($textNode); $node->parentNode->replaceChild($textNode, $node); } function convertPTag(DOMNode $node) { return trim($node->textContent); $node->ownerDocument->importNode($textNode); $node->parentNode->replaceChild($textNode, $node); } $doc = new DOMDocument(); $doc->loadHTML($HTML_string); $xpath = new DOMXpath($doc); foreach($xpath->query('/html/body/*[self::h1 or self::h2 or self::h3]') as $node) { convertHTag($node); } foreach($xpath->query('//a') as $node) { convertATag($node); } foreach($xpath->query('//strong') as $node) { convertStrongTag($node); } foreach($xpath->query('//em') as $node) { convertEmTag($node); } foreach($xpath->query('//p') as $node) { convertPTag($node); } echo $doc->textContent; /* H1: Test of h1 This is a p test. H2: Test of h2 This is a p test with a **strong emphasis** followed by this. H3: Test of h3 This here is a link: Example.com ( http://www.example.com/1 ). And this is a linebreak. Another paragraph, followed by a horizontal line: --------------- A final paragraph with *some emphasis* inside a link ( http://www.example.com/2 ). */

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.60.0130.00318.80
8.3.50.0120.00518.02
8.3.40.0040.01219.10
8.3.30.0080.00819.09
8.3.20.0080.00022.15
8.3.10.0050.00321.27
8.3.00.0040.00422.13
8.2.180.0150.00625.92
8.2.170.0040.01122.96
8.2.160.0030.01022.58
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.13
8.2.110.0100.00022.76
8.2.100.0070.00718.22
8.2.90.0000.00818.41
8.2.80.0060.00318.18
8.2.70.0030.00618.28
8.2.60.0050.00318.47
8.2.50.0090.00019.64
8.2.40.0100.00319.55
8.2.30.0080.00020.73
8.2.20.0050.00218.40
8.2.10.0000.00919.27
8.2.00.0040.00420.18
8.1.280.0110.00725.92
8.1.270.0030.00521.08
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0030.00722.48
8.1.230.0130.00321.39
8.1.220.0060.00318.04
8.1.210.0050.00318.77
8.1.200.0060.00317.85
8.1.190.0030.00517.85
8.1.180.0030.00618.10
8.1.170.0060.00319.07
8.1.160.0040.00419.22
8.1.150.0040.00419.21
8.1.140.0040.00420.63
8.1.130.0070.00017.88
8.1.120.0000.00817.78
8.1.110.0040.00417.88
8.1.100.0050.00317.79
8.1.90.0000.00717.79
8.1.80.0050.00217.74
8.1.70.0080.00017.79
8.1.60.0090.00018.00
8.1.50.0050.00317.99
8.1.40.0040.00417.84
8.1.30.0080.00018.09
8.1.20.0040.00418.00
8.1.10.0040.00417.90
8.1.00.0050.00317.85
8.0.300.0070.00020.28
8.0.290.0030.00617.13
8.0.280.0050.00218.87
8.0.270.0000.00817.70
8.0.260.0040.00417.25
8.0.250.0070.00017.39
8.0.240.0040.00417.46
8.0.230.0000.00717.43
8.0.220.0000.00817.35
8.0.210.0030.00617.39
8.0.200.0040.00417.44
8.0.190.0000.00717.35
8.0.180.0040.00417.31
8.0.170.0050.00317.38
8.0.160.0000.00917.38
8.0.150.0040.00817.30
8.0.140.0040.00417.20
8.0.130.0030.00313.85
8.0.120.0080.00017.26
8.0.110.0080.00017.38
8.0.100.0050.00317.38
8.0.90.0060.00317.42
8.0.80.0090.00917.45
8.0.70.0050.00317.45
8.0.60.0000.00817.50
8.0.50.0060.00317.21
8.0.30.0130.00317.67
8.0.20.0100.01017.77
8.0.10.0000.00817.57
8.0.00.0110.00917.11
7.4.330.0000.00615.55
7.4.320.0030.00316.94
7.4.300.0030.00316.93
7.4.290.0040.00416.95
7.4.280.0040.00416.86
7.4.270.0000.01017.05
7.4.260.0040.00416.93
7.4.250.0000.00716.93
7.4.240.0000.00917.06
7.4.230.0040.00416.96
7.4.220.0070.00016.86
7.4.210.0080.00816.96
7.4.200.0000.00717.03
7.4.140.0160.00917.86
7.4.130.0150.00917.11
7.4.120.0100.01417.07
7.4.110.0090.01016.94
7.4.100.0030.01417.03
7.4.90.0100.00916.72
7.4.80.0130.01019.39
7.4.70.0170.00016.70
7.4.60.0080.00817.02
7.4.50.0100.00716.66
7.4.40.0140.00316.96
7.4.00.0070.01015.00
7.3.330.0030.00313.52
7.3.320.0030.00313.60
7.3.310.0000.00716.71
7.3.300.0030.00316.47
7.3.290.0040.00416.63
7.3.280.0090.00816.67
7.3.260.0080.01116.83
7.3.230.0030.01316.77
7.3.210.0100.00716.64
7.3.200.0100.00616.82
7.3.190.0100.00716.97
7.3.180.0070.01016.66
7.3.170.0130.00616.88
7.3.160.0120.00916.95
7.3.120.0090.00915.14
7.3.110.0000.01815.02
7.3.100.0080.00414.94
7.3.90.0070.00715.31
7.3.80.0080.00814.97
7.3.70.0040.01115.08
7.3.60.0040.00714.70
7.3.50.0090.00914.94
7.3.40.0050.00714.73
7.3.30.0080.00815.04
7.3.20.0100.00715.79
7.3.10.1040.00715.76
7.3.00.0050.01415.97
7.2.330.0140.00316.98
7.2.320.0100.00716.88
7.2.310.0030.01417.26
7.2.300.0100.00717.24
7.2.290.0070.01017.01
7.2.240.0040.01115.25
7.2.230.0110.00415.38
7.2.220.0040.00815.48
7.2.210.0060.01215.34
7.2.200.0000.01615.07
7.2.190.0100.00715.43
7.2.180.0110.00515.24
7.2.170.0060.01215.18
7.2.160.0070.00415.21
7.2.150.0090.00616.21
7.2.140.0120.00516.19
7.2.130.0060.01416.16
7.2.120.0050.00716.18
7.2.110.0050.01016.19
7.2.100.0060.01516.28
7.2.90.0080.00716.14
7.2.80.0050.00916.33
7.2.70.0050.01016.02
7.2.60.0110.00316.29
7.2.50.0080.00816.33
7.2.40.0100.01116.18
7.2.30.0080.00916.17
7.2.20.0100.00316.13
7.2.10.0110.00716.25
7.2.00.0070.01216.16
7.1.330.0030.00615.80
7.1.320.0070.01115.83
7.1.310.0120.00316.06
7.1.300.0070.01016.08
7.1.290.0030.01015.70
7.1.280.0090.00614.94
7.1.270.0100.01014.74
7.1.260.0060.00715.05
7.1.250.0060.00815.00

preferences:
62.93 ms | 401 KiB | 5 Q