PHPHtmlParser\Dom\AbstractNode::isAncestor PHP Method

isAncestor() public method

Checks if the given node id is an ancestor of the current node.
public isAncestor ( integer $id ) : boolean
$id integer
return boolean
    public function isAncestor($id)
    {
        if (!is_null($this->getAncestor($id))) {
            return true;
        }
        return false;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Checks if the given node id is an ancestor of
  * the current node.
  *
  * @param int $id
  * @return bool
  */
 public function isAncestor($id)
 {
     if (!is_null($this->parent)) {
         if ($this->parent->id() == $id) {
             return true;
         }
         return $this->parent->isAncestor($id);
     }
     return false;
 }