2013/2/21 Tjerk Anne Meesters <datib...@php.net> > Hi, > > I found myself wanting a feature of array_filter() with which I can perform > filtering based on the array key instead of the value. > > To scratch this itch, I decided to dive into C again and just add the > feature. My proposal is to add a third argument to array_filter() that will > send the array keys to the callback. >
Hi, Why not simply _always_ push the key to the callback? Regards, Sebastian > > function myfilter($value, $key) > { > return $key > 4; > } > > array_filter([1, 2, 3, 4, 5, 6, 7], 'myfilter', true); > // returns: [6, 7] > > > The pull request can be found here: > https://github.com/php/php-src/pull/287 > > If this is useful for the language as a whole, do let me know what else I > should do to champion it. > > Thanks! > > -- > -- > Tjerk > -- github.com/KingCrunch