public function extract($attributes)
    {
        $attributes = (array) $attributes;
        $count = \count($attributes);

        $data = [];
        foreach ($this->nodes as $node) {
            $elements = [];
            foreach ($attributes as $attribute) {
                if ('_text' === $attribute) {
                    $elements[] = $node->nodeValue;
                } elseif ('_name' === $attribute) {
                    $elements[] = $node->nodeName;
                } else {
                    $elements[] = $node->getAttribute($attribute);
                }
            }

            $data[] = 1 === $count ? $elements[0] : $elements;
        }

        return $data;
    }
public function extract($attributes)
    {
        $attributes = (array) $attributes;
        $count = \count($attributes);

        $data = [];
        foreach ($this->nodes as $node) {
            $elements = [];
            foreach ($attributes as $attribute) {
                if ('_text' === $attribute) {
                    $elements[] = $node->nodeValue;
                } elseif ('_name' === $attribute) {
                    $elements[] = $node->nodeName;
                } else {
                    $elements[] = $node->getAttribute($attribute);
                }
            }

            $data[] = 1 === $count ? $elements[0] : $elements;
        }

        return $data;
    }
public function extract ( $ attributes ) { $ attributes = ( array ) $ attributes ; $ count = \ count ( $ attributes ) ; $ data = [ ] ; foreach ( $ this -> nodes as $ node ) { $ elements = [ ] ; foreach ( $ attributes as $ attribute ) { if ( '_text' === $ attribute ) { $ elements [ ] = $ node -> nodeValue ; } elseif ( '_name' === $ attribute ) { $ elements [ ] = $ node -> nodeName ; } else { $ elements [ ] = $ node -> getAttribute ( $ attribute ) ; } } $ data [ ] = 1 === $ count ? $ elements [ 0 ] : $ elements ; } return $ data ; }
Extracts information from the list of nodes.

You can extract attributes or/and the node value (_text).

Example:

$crawler->filter('h1 a')->extract(['_text', 'href']);

@param array $attributes An array of attributes

@return array An array of extracted values
Extracts information from the list of nodes .