I have an array such as ['id' => 1, 'name' => 'Fred'].
I want to call array_map on this array and also use the key inside the function. However, when I make a return, my keys will become int.
Simple example :
$arr = array('id' => 1, 'name' => 'Fred');
$result = array_map(
function ($value, $key) {
return $value;
},
$arr,
array_keys($arr)
);
var_dump($result);
Basically, I want $result to be identical to $arr in this case, but it turns my string keys into ints.