note 130366 added to function.array-find

From: Date: Fri, 13 Jun 2025 14:07:43 +0000
Subject: note 130366 added to function.array-find
Groups: php.notes 
Request: Send a blank email to php-notes+get-222219@lists.php.net to get a copy of this message
For older PHP versions, here's the proposed fallback from "mail at nititech dot de" with added PHPDoc if it's any use for you: <?php /** * Porting of PHP 8.4 function * * @template TValue of mixed * @template TKey of array-key * * @param array<TKey, TValue> $array * @param callable(TValue $value, TKey $key): bool $callback * @return ?TValue * * @see https://www.php.net/manual/en/function.array-find.php */ function array_find(array $array, callable $callback): mixed { foreach ($array as $key => $value) { if ($callback($value, $key)) { return $value; } } return null; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 107.189.8.70) ---- Manual Page -- https://php.net/manual/en/function.array-find.php Edit -- https://main.php.net/note/edit/130366 Del: integrated -- https://main.php.net/note/delete/130366/integrated Del: useless -- https://main.php.net/note/delete/130366/useless Del: bad code -- https://main.php.net/note/delete/130366/bad+code Del: spam -- https://main.php.net/note/delete/130366/spam Del: non-english -- https://main.php.net/note/delete/130366/non-english Del: in docs -- https://main.php.net/note/delete/130366/in+docs Del: other reasons-- https://main.php.net/note/delete/130366 Reject -- https://main.php.net/note/reject/130366 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#222219) next »