pQuery\DomNode::getChildrenByMatch PHP Method

getChildrenByMatch() public method

Finds children using the {$link match()} function
public getChildrenByMatch ( $conditions, boolean | integer $recursive = true, boolean $check_self = false, $custom_filters = [] ) : array
$conditions See {$link match()}
$recursive boolean | integer Check recursively
$check_self boolean Include this node in search?
$custom_filters See {$link match()}
return array
    function getChildrenByMatch($conditions, $recursive = true, $check_self = false, $custom_filters = array())
    {
        $count = $this->childCount();
        if ($check_self && $this->match($conditions, true, $custom_filters)) {
            $res = array($this);
        } else {
            $res = array();
        }
        if ($count > 0) {
            if (is_int($recursive)) {
                $recursive = $recursive > 1 ? $recursive - 1 : false;
            }
            for ($i = 0; $i < $count; $i++) {
                if ($this->children[$i]->match($conditions, true, $custom_filters)) {
                    $res[] = $this->children[$i];
                }
                if ($recursive) {
                    $res = array_merge($res, $this->children[$i]->getChildrenByMatch($conditions, $recursive, false, $custom_filters));
                }
            }
        }
        return $res;
    }
DomNode