On 18 June 2013 18:24, Sherif Ramadan <theanomaly...@gmail.com> wrote:
> > Nevertheless, I'd say go with a new array_filter_key() function, because > > that permits using existing one-parameter functions like that strlen as a > > callback, instead of forcing two-parameter callback functions. > > > The current patch does not force the callback to take two arguments. By > default the existing behavior is maintained since the third argument is > false by default. I still don't hear a good argument for adding a new > function. I'm very much on the "new function" side of the fence. Basic (one-word) arguments for this include familiarity and simplicity. Familiarity, since we're used to *_key functions for arrays. It will come as absolutely no surprise to see the _key function spring up out of nowhere and its use is blindingly obvious for anyone who has ever used array_filter(). Simplicity since, err.. what were those flags again? is it $key first or $value? is there an ARRAY_FILTER_BOTH? Also, I don't pretend my time with PHP covers everything that everyone has ever done or wanted to do, but I cannot think of a time when I wanted to filter an array on both the key *and* the value at the same time: of course, it's easy to make up use cases.