Would anyone happen to know if there is an even more efficient way or single function that will achieve the below without the need for a foreach loop? I understand that it will have practically no performance issue on the below however I'm always looking for new and hopefully more efficient ways to code.
(Push first element value to key, push second element value to new key value, unset old data)
Input
Array
(
[0] => Array
(
[supplier_id] => 1
[supplier_company] => Company Alpha
)
[1] => Array
(
[supplier_id] => 2
[supplier_company] => Company Beta
)
)
Function
foreach ($suppliers as $key => $value) {
$new_array[$value['supplier_id']] = $value['supplier_company'];
}
Output
Array
(
[1] => Company Alpha
[2] => Company Beta
)