Documentation

Predicate

Enable filtering a record based on its value and/or its offset.

The class can be used directly with PHP's

  1. array_filter with the ARRAY_FILTER_USE_BOTH flag.
  2. CallbackFilterIterator class.

Table of Contents

Methods

__invoke()  : bool
The class predicate method.
filter()  : Iterator
Filters elements of an iterable structure using the class predicate method.

Methods

__invoke()

The class predicate method.

public __invoke(mixed $value, string|int $key) : bool

Evaluates each element of an iterable structure based on its value and its offset. The method must return true if the predicate is satisfied, false otherwise.

Parameters
$value : mixed
$key : string|int
Return values
bool

filter()

Filters elements of an iterable structure using the class predicate method.

public filter(iterable<string|int, mixed> $value) : Iterator
Parameters
$value : iterable<string|int, mixed>
Tags
see
Predicate::__invoke
Return values
Iterator

        
On this page

Search results