A general solution for the problem of wanting to know the keys in the callback, and/or retain the key association in the returned array:
<?php
function array_map_assoc(callable $callback, array $array, array ...$arrays) {
$keys = array_keys($array);
array_unshift($arrays, $keys, $array);
return array_combine($keys, array_map($callback, ...$arrays));
}
?>
Because it uses array_map() directly, it behaves the same way in regard to ignoring the keys of subsequent array arguments. It also has the same variadic signature.