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

Breadcrumb

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

function Matches::unique

Remove all duplicated matches

Return value

$this

2 calls to Matches::unique()
Matches::map in vendor/mck89/peast/lib/Peast/Selector/Matches.php
Replaces all the matches with the result of the given function. The function will receive the node and its parent as arguments and must return an array of matches
Matches::merge in vendor/mck89/peast/lib/Peast/Selector/Matches.php
Merges the current object with the other given Matches objects

File

vendor/mck89/peast/lib/Peast/Selector/Matches.php, line 134

Class

Matches
Selector matches class

Namespace

Peast\Selector

Code

public function unique() {
    $newMatches = array();
    $newNodes = array();
    foreach ($this->matches as $match) {
        if (!in_array($match[0], $newNodes, true)) {
            $newMatches[] = $match;
            $newNodes[] = $match[0];
        }
    }
    $this->matches = $newMatches;
    return $this;
}
RSS feed
Powered by Drupal