You are here

public function QueryPath::each in QueryPath 7.3

Same name and namespace in other branches
  1. 6 QueryPath/QueryPath.php \QueryPath::each()
  2. 7.2 QueryPath/QueryPath.php \QueryPath::each()

File

QueryPath/QueryPath.php, line 609

Class

QueryPath

Code

public function each($callback) {
  if (is_callable($callback)) {
    $i = 0;
    foreach ($this->matches as $item) {
      if (call_user_func($callback, $i, $item) === FALSE) {
        return $this;
      }
      ++$i;
    }
  }
  else {
    throw new QueryPathException('Callback is not callable.');
  }
  return $this;
}