- Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.30
- Parse error: syntax error, unexpected ':' in /in/1hIVg on line 27
Process exited with code 255.
<?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());