(PHP 8)
DOMChildNode::remove — Removes the node
This function has no parameters.
No value is returned.
Removing a nodes in a loop over a dom structure can breac the iterator so
foreach ($element->childNodes AS $child)
{
$child->remove();
}
isn't going to do what it loocs lique it should. The loop body will only run once regardless of how many children exist.