Don’t make fun of me if you already knew the answer. However, for a long time I have always been sad that I can’t use array keys with array_map().

It turns out, however, that this is not exactly true. Check this out:

array_map(function($key, $value) {
    return [$key => $value];
}, array_keys($my_array), $my_array);

How do you like that?

I feel like this is (or at least should be) common knowledge that nobody told me about. I missed a boat somewhere, but as embarassing as that is, I thought I'd share in case there is somebody else out there who also wasn't filled in on this handy little trick.