Is there a built-in PHP function that does the following?
function array_index(array $values, callable $getKey): array
{
$result = [];
foreach ($values as $value) {
$result[$getKey($value)] = $value;
}
return $result;
}
I think I've reviewed all array_*() functions, but am surprised that this use case is not covered by any native function.