作为 MySQL 查询的结果,我得到了以下数组:
Array
(
[0] => Array
(
[id] => 11
[owner] => Mark
)
[1] => Array
(
[id] => 10
[owner] => David
)
[2] => Array
(
[id] => 9
[owner] => Poul
)
[3] => Array
(
[id] => 8
[owner] => Peter
)
[4] => Array
(
[id] => 7
[owner] => Peter
)
[5] => Array
(
[id] => 6
[owner] => Lucas
)
)
有没有办法修改它,使用 PHP 函数并省略该foreach
过程?
我希望它看起来如下:
Array
(
11 => Mark
10 => David
9 => Poul
8 => Peter
7 => Peter
6 => Lucas
)
id
所以,基本上它应该从和owner
值构建这个数组。喜欢id => owner
。
那可能吗?