3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cssClasses = [ 'container' => 'width: 100%;padding-right: 15px;padding-left: 15px;margin-right: auto;margin-left: auto;', 'card' => 'position: relative;display: -ms-flexbox;display: flex;-ms-flex-direction: column;flex-direction: column;min-width: 0;word-wrap: break-word;background-color: #fff;background-clip: border-box;border: 1px solid rgba(0, 0, 0, 0.125);border-radius: 0.25rem;' ]; $html = <<<'EOD' <div class="container"> 01 <div class="card"> 02 </div> </div> EOD; $dom = new DOMDocument; $dom->loadHTML($html); $divNL = $dom->getElementsByTagName('div'); for ($i = $divNL->length - 1; $i >= 0; $i--) { $node = $divNL->item($i); $table = $dom->createElement('table'); $tr = $dom->createElement('tr'); $td = $dom->createElement('td'); $table->appendChild($tr); $tr->appendChild($td); foreach ($node->attributes as $attr) { $td->appendChild($attr); } $styles = array_reduce( preg_split('~\s+~u', $td->getAttribute('class')), function($c, $i) use ($cssClasses) { return isset($cssClasses[$i]) ? $cssClasses[$i] . $c : $c; }, $td->getAttribute('style') ); if ( !empty($styles) ) $td->setAttribute('style', $styles); foreach ($node->childNodes as $childNode) { $td->appendChild($childNode->cloneNode(true)); } $node->parentNode->replaceChild($table, $node); } $result = ''; foreach ($dom->getElementsByTagName('body')->item(0)->childNodes as $childNode) { $result .= $dom->saveHTML($childNode); } echo $result;

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.1.130.0070.00020.40
8.1.120.0060.00317.86
8.1.110.0000.00817.85
8.1.100.0040.00417.91
8.1.90.0110.00017.81
8.1.80.0030.00617.90
8.1.70.0030.00317.90
8.1.60.0040.00417.95
8.1.50.0080.00017.87
8.1.40.0030.00617.94
8.1.30.0040.00418.03
8.1.20.0030.00618.02
8.1.10.0040.00418.00
8.1.00.0030.00617.93
8.0.260.0030.00320.23
8.0.250.0030.00317.50
8.0.240.0030.00317.43
8.0.230.0000.00717.56
8.0.220.0000.00717.45
8.0.210.0000.00817.49
8.0.200.0000.00717.50
8.0.190.0040.00417.56
8.0.180.0060.00317.48
8.0.170.0060.00317.39
8.0.160.0000.00717.37
8.0.150.0060.00317.39
8.0.140.0000.00817.38
8.0.130.0060.00013.83
8.0.120.0050.00317.47
8.0.110.0000.00717.43
8.0.100.0030.00617.52
8.0.90.0060.00317.68
8.0.80.0060.01017.52
8.0.70.0040.00417.42
8.0.60.0060.00317.40
8.0.50.0000.00817.29
8.0.30.0070.01017.75
8.0.20.0150.01117.64
8.0.10.0000.00717.46
8.0.00.0120.00617.33
7.4.330.0060.00015.55
7.4.320.0000.00717.00
7.4.300.0030.00317.12
7.4.290.0030.00317.03
7.4.280.0040.00417.13
7.4.270.0000.00817.07
7.4.260.0000.00817.03
7.4.250.0000.00717.05
7.4.240.0030.00517.09
7.4.230.0000.00717.29
7.4.220.0000.00717.15
7.4.210.0090.00717.24
7.4.200.0000.00717.24
7.4.130.0150.01217.11
7.4.120.0030.01516.99
7.4.110.0150.00817.26
7.4.100.0040.01317.16
7.4.90.0120.00617.05
7.4.80.0030.01719.39
7.4.70.0120.00617.13
7.4.60.0030.01317.02
7.4.50.0040.01117.03
7.4.40.0060.01617.21
7.4.00.0070.01115.41
7.3.330.0060.00013.71
7.3.320.0000.00513.77
7.3.310.0000.00716.79
7.3.300.0000.00716.90
7.3.290.0030.01216.74
7.3.280.0040.01316.71
7.3.260.0090.01017.04
7.3.240.0090.00916.84
7.3.230.0130.01316.83
7.3.210.0110.00917.06
7.3.200.0050.01116.91
7.3.190.0060.00917.11
7.3.180.0130.00316.75
7.3.170.0060.01616.95
7.3.160.0030.01316.84
7.3.70.0070.00714.98
7.3.60.0130.00314.83
7.3.50.0080.00915.07
7.3.40.0110.00314.75
7.3.30.0030.01814.96
7.3.20.0710.01215.18
7.3.10.0140.00515.07
7.3.00.0290.00314.92
7.2.330.0090.00917.17
7.2.320.0100.00617.00
7.2.310.0090.00917.10
7.2.300.0140.00317.05
7.2.290.0140.01017.08
7.2.200.0120.01215.24
7.2.190.0100.01015.00
7.2.180.0030.01415.27
7.2.170.0100.00715.05
7.2.160.0110.00715.13
7.2.150.0180.00615.16
7.2.140.0130.01015.43
7.2.130.0260.01015.11
7.2.120.0250.00015.06
7.2.110.0170.00715.41
7.2.100.0090.01215.16
7.2.90.0140.00415.29
7.2.80.0100.01015.48
7.2.70.0110.00815.33
7.2.60.0230.00815.25
7.2.50.0170.00615.25
7.2.40.0250.00415.19
7.2.30.0070.01315.29
7.2.20.0190.00915.04
7.2.10.0140.01115.19
7.2.00.0250.00615.24
7.1.300.0180.00514.08
7.1.290.0240.00614.21
7.1.280.0160.01013.97
7.1.270.0190.00414.35
7.1.260.0200.00714.24
7.1.250.0280.00414.29

preferences:
11 ms | 406 KiB | 5 Q