Send a blank email to [email protected] to get a copy of this message
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.
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