After executing the fetch query, I got an array of results:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
How do I get an array of results like this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
What should I do?
My question is
1 |
|
大瓶可乐@php.cn2023-07-17 10:37:08
从SQL查询中直接实现这个功能是不可能的,但是你可以检索所有的数据,然后重新映射数组。
使用PHP 5.5的array_column()函数,你可以做类似以下的操作:
1 2 3 4 |
|
对于较早版本的PHP,可以使用array_map()函数来代替。
1 2 3 4 5 6 7 8 9 |
|
你应该按照以下方式创建一个新的数组变量。
1 2 3 4 5 6 7 |
|
coco2023-08-09 18:49:59
Hello, Mr. Wang, I very much agree with your skills and hope to have further communication opportunities with you. Can you please add us via WeChat or email?