3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getColor($domnode) { while($domnode->parentNode) { if ($domnode->parentNode->getAttribute('color')) { return $domnode->parentNode->getAttribute('color'); } } } $html = '<FONT FACE="League" SIZE="15" COLOR="#000000"><font COLOR="#ff00ff" SIZE="18"><b><font SIZE="23"><font SIZE="27"><font SIZE="23"><font SIZE="18"><font SIZE="23">Moet Flip make-up dragen? <br />Stem mee in de poll!!</font></font></font></font></font></b></font><br /></FONT>'; //var_dump(strip_tags($html, '<br>')); $dom = new DOMDOcument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); $nodes = $xpath->evaluate("/html/body//text()"); foreach ($nodes as $node) { $color = getColor($node); if ($color) { $span = $document->createElement('span'); $span->setAttribute('style', color: ' . $color . ';'); $node->parentNode->replaceChild($span, $node); } } var_dump($dom->saveHTML());

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)
5.4.300.0150.03012.52
5.4.290.0130.03512.52
5.4.280.0080.03512.41
5.4.270.0080.03412.41
5.4.260.0100.03812.41
5.4.250.0050.04212.41
5.4.240.0100.04312.41
5.4.230.0090.04412.40
5.4.220.0100.03512.41
5.4.210.0090.03512.41
5.4.200.0060.03912.40
5.4.190.0060.03812.40
5.4.180.0080.04012.40
5.4.170.0090.03912.41
5.4.160.0060.04212.40
5.4.150.0070.03912.39
5.4.140.0060.04312.09
5.4.130.0070.04112.07
5.4.120.0050.04312.04
5.4.110.0060.03912.03
5.4.100.0040.04212.03
5.4.90.0070.03812.03
5.4.80.0030.04212.03
5.4.70.0110.03312.02
5.4.60.0100.03112.03
5.4.50.0050.03612.03
5.4.40.0050.03812.01
5.4.30.0070.03512.01
5.4.20.0060.04112.01
5.4.10.0050.03712.01
5.4.00.0040.04211.50
5.3.280.0090.03712.70
5.3.270.0110.05312.73
5.3.260.0100.05312.72
5.3.250.0050.05712.72
5.3.240.0130.03712.72
5.3.230.0060.05412.71
5.3.220.0100.05012.68
5.3.210.0080.05512.68
5.3.200.0090.04112.68
5.3.190.0110.04812.68
5.3.180.0150.08412.68
5.3.170.0110.05312.67
5.3.160.0120.05212.67
5.3.150.0120.05112.67
5.3.140.0050.05012.66
5.3.130.0060.04212.66
5.3.120.0060.04412.65
5.3.110.0120.04012.66
5.3.100.0050.05312.12
5.3.90.0060.05312.11
5.3.80.0130.08412.09
5.3.70.0160.09612.09
5.3.60.0110.04712.08
5.3.50.0040.04012.03
5.3.40.0030.04012.03
5.3.30.0070.03811.99
5.3.20.0130.03411.77
5.3.10.0090.03911.73
5.3.00.0060.04811.72

preferences:
134.35 ms | 1398 KiB | 7 Q