Re: array_reduce callback key

From: Date: Wed, 17 Jul 2024 07:55:20 +0000
Subject: Re: array_reduce callback key
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-124454@lists.php.net to get a copy of this message
While it *is* indeed a workaround, you can very easily access the values of the array from the keys, since that literally is what the keys are for. While I also think it's weird that not all php array functions with callbacks do pass the key as an argument, and while I also stumbled upon that problem in the past myself multiple times, I also think it is worth taking the time to consider what other people from this mailing list are bringing up. If it could indeed break internal callbacks, then I think using the workaround could be a better idea than potentially breaking other things. On Wed, Jul 17, 2024 at 2:38 AM Bilge <bilge@scriptfusion.com> wrote: > > On Wed, 17 Jul 2024, 01:29 mickmackusa, <mickmackusa@gmail.com> wrote: >> >> It is untrue that you "can't access it"; you just need to use an array of >> keys as the input array. > > It is absolutely true and your workaround is just that; a workaround that doesn't work at > all when you also need the value. > > Cheers, > Bilge

« previous php.internals (#124454) next »