PHPHtmlParser\Dom\InnerNode::replaceChild PHP Method

replaceChild() public method

Removes the child with id $childId and replace it with the new child $newChild.
public replaceChild ( integer $childId, AbstractNode $newChild )
$childId integer
$newChild AbstractNode
    public function replaceChild($childId, AbstractNode $newChild)
    {
        $oldChild = $this->getChild($childId);
        $keys = array_keys($this->children);
        $index = array_search($childId, $keys, true);
        $keys[$index] = $newChild->id();
        $this->children = array_combine($keys, $this->children);
        $this->children[$newChild->id()] = $newChild;
        unset($oldChild);
    }