- iterator_to_array: documentation ( source)
<?php
$html = <<<'HTML'
<!DOCTYPE html><html><body>
<small>0</small>
<small>1</small>
<small>2</small>
<small>3</small>
</body></html>
HTML;
$dom = new DOMDocument;
$dom->loadHTML($html);
$nodeArray = iterator_to_array($dom->getElementsByTagName('small'));
foreach($nodeArray as $node) {
$node->parentNode->removeChild($node);
}
echo $dom->saveHTML();