You are here

public function Crawler::each in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Crawler.php \Symfony\Component\DomCrawler\Crawler::each()

Calls an anonymous function on each node of the list.

The anonymous function receives the position and the node wrapped in a Crawler instance as arguments.

Example:

$crawler->filter('h1')->each(function ($node, $i) { return $node->text(); });

Parameters

\Closure $closure An anonymous function:

Return value

array An array of values returned by the anonymous function

File

vendor/symfony/dom-crawler/Crawler.php, line 353

Class

Crawler
Crawler eases navigation of a list of \DOMElement objects.

Namespace

Symfony\Component\DomCrawler

Code

public function each(\Closure $closure) {
  $data = array();
  foreach ($this as $i => $node) {
    $data[] = $closure($this
      ->createSubCrawler($node), $i);
  }
  return $data;
}