pQuery\DomNode::getChild PHP Method

getChild() public method

Get childnode
public getChild ( integer | DomNode $child, boolean $ignore_text_comments = false ) : DomNode
$child integer | DomNode Index, negative to count from end
$ignore_text_comments boolean Ignore text/comments with index calculation
return DomNode
    function &getChild($child, $ignore_text_comments = false)
    {
        if (!is_int($child)) {
            $child = $this->findChild($child);
        } elseif ($child < 0) {
            $child += $this->childCount($ignore_text_comments);
        }
        if ($ignore_text_comments) {
            $count = 0;
            $last = null;
            //foreach($this->children as &$c) {
            //	if (!$c->isTextOrComment()) {
            //		if ($count++ === $child) {
            //			return $c;
            //		}
            //		$last = $c;
            //	}
            //}
            foreach (array_keys($this->children) as $k) {
                if (!$this->children[$k]->isTextOrComment()) {
                    if ($count++ === $child) {
                        return $this->children[$k];
                    }
                    $last = $this->children[$k];
                }
            }
            return $child > $count ? $last : null;
        } else {
            return $this->children[$child];
        }
    }
DomNode