public function QueryPath::prev in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::prev()
- 7.2 QueryPath/QueryPath.php \QueryPath::prev()
File
- QueryPath/
QueryPath.php, line 1462
Class
Code
public function prev($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)) {
if (qp($m, NULL, $this->options)
->is($selector)) {
$found
->attach($m);
break;
}
}
else {
$found
->attach($m);
break;
}
}
}
}
$this
->setMatches($found);
return $this;
}