QueryPath\DOMQuery::prevUntil PHP Method

prevUntil() public method

For each element in the DOMQuery, get all previous siblings. If a selector is provided, only matching siblings will be retrieved.
See also: prev()
See also: nextAll()
See also: siblings()
See also: contents()
See also: children()
Since: 2.1
Author: eabrand
public prevUntil ( string $selector = null )
$selector string A valid CSS 3 selector.
    public function prevUntil($selector = null)
    {
        $found = new \SplObjectStorage();
        foreach ($this->matches as $m) {
            while (isset($m->previousSibling)) {
                $m = $m->previousSibling;
                if ($m->nodeType === XML_ELEMENT_NODE) {
                    if (!empty($selector) && QueryPath::with($m, null, $this->options)->is($selector)) {
                        break;
                    } else {
                        $found->attach($m);
                    }
                }
            }
        }
        return $this->inst($found, null, $this->options);
    }