php - Convert associative array to key=>value -
i have following array
array ( [0] => array ( [id] => 5 [name] => 44 ) [1] => array ( [id] => 9 [name] => 55 ) )
i need convert to
array( '5' => '44', '9' => '55' )
i tried function of arrays php.net not figure out how it
did try foreach
?
$result = array(); foreach($yourarray $entry) { $result[$entry['id']] = $entry['name']; }
Comments
Post a Comment