Creates a Closure that selects only the specified indexes/keys from an array or iterable.
/**
* @param string ...$indexes The keys to keep.
* @return Closure(iterable<int|string, mixed>):mixed[]
*/
Arrays\pick(string ...$indexes): ClosureWhen Arrays\pick() is called, it returns the following Closure which can be used like a regular function.
/**
* @param iterable<int|string, mixed> $source
* @return mixed[]
*/
$function (iterable $source): arrayThis can be used to create a simple closure which can be used as a regular function.
$idAndName = Arrays\pick('id', 'name');
print_r($idAndName(['id' => 1, 'name' => 'Ada', 'secret' => 'xxx']));
// ['id' => 1, 'name' => 'Ada']