PHPHtmlParser\Dom\InnerNode::removeChild PHP Method

removeChild() public method

Removes the child by id.
public removeChild ( integer $id )
$id integer
    public function removeChild($id)
    {
        if (!isset($this->children[$id])) {
            return $this;
        }
        // handle moving next and previous assignments.
        $next = $this->children[$id]['next'];
        $prev = $this->children[$id]['prev'];
        if (!is_null($next)) {
            $this->children[$next]['prev'] = $prev;
        }
        if (!is_null($prev)) {
            $this->children[$prev]['next'] = $next;
        }
        // remove the child
        unset($this->children[$id]);
        //clear any cache
        $this->clear();
        return $this;
    }

Usage Example

 /**
  * Removes this node and all its children from the
  * DOM tree.
  *
  * @return void
  */
 public function delete()
 {
     if (!is_null($this->parent)) {
         $this->parent->removeChild($this->id);
     }
     $this->parent = null;
 }