基本上,我有一个数组,其中每个元素都是元素的键/值对,如下所示:
[myArray] => Array
[0] => Array
[id] => 121
[name] => Value1
[1] => Array
[id] => 125
[name] => Value2
[2] => Array
[id] => 129
[name] => Value3
....
我想将其转换为:
[myArray] => Array
[121] => Value1
[125] => Value2
[129] => Value3
....
所以'id'元素成为键,'name'元素成为值。PHP是否有内置的东西(或者有一个聪明的技巧)来做到这一点?如果有更清洁的东西可用,我想避免明显的 foreach() 循环......