Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-02 Thread Pierre
Le 02/06/2023 à 10:57, Janusz Szczypka a écrit : You are right about speed penalty for using those functions over simple loops, however if we would stick to that point of view, we should deprecate and remove array_filter, array_map, array_walk, array_u... I'm not sure they deserve deprecation

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-02 Thread Janusz Szczypka
W dniu 2.06.2023 o 03:24, Hans Henrik Bergan pisze: sounds like array_find could be implemented by just adding a new flag for array_filter's $mode: ARRAY_FILTER_STOP_ON_FIRST_MATCH or some such? array_filter is guaranteed to always return an array and we should not change it. Flags are used j

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-02 Thread Janusz Szczypka
W dniu 2.06.2023 o 02:14, Casper Langemeijer pisze: On Thu, Jun 1, 2023, at 18:02, Janusz Szczypka wrote: array_find(): This function would allow developers to find the first element in an array that satisfies a specific condition. The condition would be defined by a callback function. This wo

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-01 Thread Hans Henrik Bergan
sounds like array_find could be implemented by just adding a new flag for array_filter's $mode: ARRAY_FILTER_STOP_ON_FIRST_MATCH or some such? On Fri, 2 Jun 2023 at 02:15, Casper Langemeijer wrote: > > On Thu, Jun 1, 2023, at 18:02, Janusz Szczypka wrote: > > array_find(): This function would all

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-01 Thread Casper Langemeijer
On Thu, Jun 1, 2023, at 18:02, Janusz Szczypka wrote: > array_find(): This function would allow developers to find the first element > in > an array that satisfies a specific condition. The condition would be defined > by a callback function. This would actually be an alternative to a simple fo

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-01 Thread Jorg Sowa
Hey, Native implementation of the function array_find would decrease number of lines needed to perform basic loops over the arrays from 4-6 lines to just 1. And I recollect a few times when the argument of reducing lines of code needed to type was a valid reason of implementing the change. Moreove

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-01 Thread Tim Düsterhus
Hi On 6/1/23 18:29, Larry Garfield wrote: As with the array_group thread: What is the argument to put these functions in hard to update C, rather than PHP that is easy to download with Composer? "could be a nice addition" is not a compelling argument. Is it substantially faster? It is trul

Re: [PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-01 Thread Larry Garfield
On Thu, Jun 1, 2023, at 4:02 PM, Janusz Szczypka wrote: > Dear PHP Internals, > > I would like to propose new functions to search in arrays: array_find() and > array_find_key(). > > array_find(): This function would allow developers to find the first > element in > an array that satisfies a specif

[PHP-DEV] Proposal: addition of array_find() and array_find_key() functions

2023-06-01 Thread Janusz Szczypka
Dear PHP Internals, I would like to propose new functions to search in arrays: array_find() and array_find_key(). array_find(): This function would allow developers to find the first element in an array that satisfies a specific condition. The condition would be defined by a callback function