Predicate
in
Enable filtering a record based on its value and/or its offset.
The class can be used directly with PHP's
- array_filter with the ARRAY_FILTER_USE_BOTH flag.
- 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
boolfilter()
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>