find.php
Table of Contents
Functions
- find() : mixed
- Returns the first element of an array that satisfies a predicate.
Functions
find()
Returns the first element of an array that satisfies a predicate.
find(array<int|string, mixed> $items, callable $predicate[, mixed $default = null ]) : mixed
The $predicate callback is invoked as fn( $value , $key ) for every entry,
in iteration order, until it returns a truthy value. If no element matches, the
$default value is returned.
Parameters
- $items : array<int|string, mixed>
-
The array to search.
- $predicate : callable
-
The test callback:
fn( $value , $key ): bool. - $default : mixed = null
-
The value returned when no element matches. Default
null.
Tags
Return values
mixed —The first matching value, or $default.