Re: RFC [Discussion] array_column results grouping

From: Date: Tue, 07 Dec 2021 03:01:12 +0000
Subject: Re: RFC [Discussion] array_column results grouping
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-116581@lists.php.net to get a copy of this message
> > Better map/filter/reduce primitives in PHP would be dandy, but they have > nothing to do with array grouping. They're a separate operation that should > be composed with grouping. Packing them all into a single function sounds > like a terrible idea. > > If we wanted that... that's called list comprehensions, which I would > support and even tried to rally support for a few years ago, but got met > with a big shrug. :-) array_group is just a simple handy tool which can manipulate a bunch of data without touching SQL, DQL, query builder, or any producer anymore just to align the output to the need. Of course we can code with whatever programming paradigm or style we want, especially if the algorithm is much more complex. Here, i offer you the very basic functionality and without external library. So my coworker does not have to dig into that library, or ask me. The original proposal is to offer grouping, and may be to avoid foreach. I think if the only purpose is to group an array, it is halfly baked function- ality. Previously, I had shown you that foreach is not too bad to use. Otherwise, I will suggest to the author don't bother with new function, you're wasting your time. With that original proposed functionality, We have to use an additional foreach or function call even though it is a basic operation. Moreover, the original purpose is preserved, if we do not give any optional params.

« previous php.internals (#116581) next »