[...$carry, ...$value], initial: [], ); } /** * Checks if a callback returns true for at least one item in a collection. * @param callable(mixed $value, mixed $key): bool $callback */ function some(iterable $collection, callable $callback): bool { foreach ($collection as $key => $value) { if ($callback($value, $key)) { return true; } } return false; } /** * Checks if a callback returns true for all item in a collection. * @param callable(mixed $value, string|number $key): bool $callback */ function every(iterable $collection, callable $callback): bool { foreach ($collection as $key => $value) { if (! $callback($value, $key)) { return false; } } return true; } /** * Returns an array containing only those entries in the array whose key is in the supplied keys. */ function select_keys(array $array, array $keys): array { return array_filter( $array, static fn (string $key) => contains( $key, $keys, ), ARRAY_FILTER_USE_KEY, ); }