function 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 320
Class
- Crawler
- Crawler eases navigation of a list of \DOMNode objects.
Namespace
Symfony\Component\DomCrawlerCode
public function each(\Closure $closure) : array {
$data = [];
foreach ($this->nodes as $i => $node) {
$data[] = $closure($this->createSubCrawler($node), $i);
}
return $data;
}