I have a 2d Array (returned from PDO MySQL DB) that is of the form
{
[0] => {
"ID" => 1,
"Name" => "Name1"
},
[1] => {
"ID" => 2,
"Name" => "Name2"
},
[2] => {
"ID" => 3,
"Name" => "Name3"
}
}
Is there an elegant/efficient solution to transform it to
{
[1] => "Name1",
[2] => "Name2",
[3] => "Name3"
}
I know I could loop through and create the array that way, but i feel like that may be less efficient than something like a fancy array_map.
Basically I want something like...
array_map(
function ($value) {
return $value['ID']=>$value['Name'];
}, $ResultArray);