-
Notifications
You must be signed in to change notification settings - Fork 149
Description
I would love to see filter() be able to operate on associative arrays. There are so many cases you have a list of name-value pairs and you want to reduce this to a subset which is defined by a list of either values to exclude (black-list approach) or a list of to include only a list (white-list approach). I had hoped to have something like:
$start = array ( "one" => "monkey" , "two" => "donkey" , "three" => "beetle" );
$filter = array ( "two", "three" );
$list = ___::filter( $start, function ($value,$key) {
return in_array( $key , $filter );
});
I'd be interested to know if this is better achieved a different way (as I'm still relatively new to underscore) or whether this would be seen as a worthwhile extension to the functionality if I were to fork it off.