我有以下数组
Array
(
[0] => Array
(
[id] => 5
[name] => 44
)
[1] => Array
(
[id] => 9
[name] => 55
)
)
我需要将其转换为
array( '5' => '44', '9' => '55' )
我尝试了php.net的所有数组功能,但我无法弄清楚如何做到这一点
答案 0 :(得分:6)
你试过foreach
吗?
$result = array();
foreach($yourarray as $entry) {
$result[$entry['id']] = $entry['name'];
}