pQuery\DomNode::select PHP Method

select() public method

Performs css query on node
public select ( string $query = '*', integer | boolean $index = false, boolean | integer $recursive = true, boolean $check_self = false ) : DomNode[] | DomNode
$query string
$index integer | boolean True to return node instead of array if only 1 match, false to return array, int to return match at index, negative int to count from end
$recursive boolean | integer
$check_self boolean Include this node in search or only search child nodes
return DomNode[] | DomNode Returns an array of matching {@link DomNode} objects or a single {@link DomNode} if `$index` is not false.
    function select($query = '*', $index = false, $recursive = true, $check_self = false)
    {
        $s = new $this->selectClass($this, $query, $check_self, $recursive);
        $res = $s->result;
        unset($s);
        if (is_array($res) && $index === true && count($res) === 1) {
            return $res[0];
        } elseif (is_int($index) && is_array($res)) {
            if ($index < 0) {
                $index += count($res);
            }
            return $index < count($res) ? $res[$index] : null;
        } else {
            return $res;
        }
    }
DomNode