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

Breadcrumb

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

function CollectionInterface::where

Create a new collection where the result of the given property, method, or array key of each item in the collection equals the given value.

This will always leave the original collection untouched and will return a new one.

Parameters

string | null $propertyOrMethod The property, method, or array key: to evaluate. If `null`, the element itself is compared to $value.

mixed $value The value to match.:

Return value

CollectionInterface<T>

Throws

InvalidPropertyOrMethod if the $propertyOrMethod does not exist on the elements in this collection.

UnsupportedOperationException if unable to call where() on this collection.

1 method overrides CollectionInterface::where()
AbstractCollection::where in vendor/ramsey/collection/src/AbstractCollection.php

File

vendor/ramsey/collection/src/CollectionInterface.php, line 175

Class

CollectionInterface
A collection represents a group of values, known as its elements.

Namespace

Ramsey\Collection

Code

public function where(?string $propertyOrMethod, mixed $value) : self;

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal