Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Crawler.php

function Crawler::reduce

Reduces the list of nodes by calling an anonymous function.

To remove a node from the list, the anonymous function must return false.

Parameters

\Closure $closure An anonymous function:

File

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

Class

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

Namespace

Symfony\Component\DomCrawler

Code

public function reduce(\Closure $closure) : static {
    $nodes = [];
    foreach ($this->nodes as $i => $node) {
        if (false !== $closure($this->createSubCrawler($node), $i)) {
            $nodes[] = $node;
        }
    }
    return $this->createSubCrawler($nodes);
}
RSS feed
Powered by Drupal