Reputation: 148
I have the following array
Array
(
[0] => Array
(
[id] => 5
[name] => 44
)
[1] => Array
(
[id] => 9
[name] => 55
)
)
i need to convert it to
array( '5' => '44', '9' => '55' )
i tried all function of arrays from php.net but i could not figure out how to do it
Upvotes: 2
Views: 2364
Reputation: 53715
did you try foreach
?
$result = array();
foreach($yourarray as $entry) {
$result[$entry['id']] = $entry['name'];
}
Upvotes: 6