Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:123442 php.internals:123443 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: by qa.php.net (Postfix, from userid 65534) id 2D7C71A009D; Tue, 28 May 2024 08:20:12 +0000 (UTC) To: internals@lists.php.net,=?UTF-8?Q?Joshua_R=C3=BCsweg?= , Message-ID: <37dd1379-d9fb-478b-b016-3bc0f1aaae24@daikaras.lt> Date: Tue, 28 May 2024 11:20:12 +0300 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PHP-DEV] RFC [Discussion]: array_find PHP internals References: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> Content-Language: en-US In-Reply-To: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 90.135.122.248 From: webmaster@daikaras.lt (Daikaras) On 2024.04.07 17:20, Joshua Rüsweg wrote: > Hi > I have created an RFC to add the function array_find which returns the > first element for which a predicate callback returns true. This is a > function which I missed often. Furthermore this type of function is > implemented with other programming languages like C++, JavaScript and > Rust, too. > You can find the RFC at: > https://wiki.php.net/rfc/array_find > Proof of concept implementation is in: > https://github.com/joshuaruesweg/php-src/ > commit/9f3fc252b92f534d498e5f1e6a463e15f45da208 > I'm looking forward to your feedback. > Cheers > Joshua Rüsweg > Late to the party but I'm wondering why are `array_find()` and `array_find_key()` under the same vote? These should have been split so `array_find()` could be rejected. I think it was agreed in [Add functions array_key_first() and array_key_last()](https://wiki.php.net/rfc/array_key_first_last) RFC that 1) returning null when value not found is wrong behavior and 2) it's pointless having a function for returning a value when identical function for returning a key exists.