删除php-mysql结果行中的重复字段 [英] remove duplicating fields in php-mysql result rows
本文介绍了删除php-mysql结果行中的重复字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
执行查询并遍历结果以组成记录数组后,当我var_dump该记录时,会看到以下内容:
After I executed a query and loop through the result to compose an array of records, when I var_dump that array, I see the following:
array
0 =>
array
0 => string '1'
'id' => string '1'
1 => string 'record one'
'name' => string 'record one'
1 =>
array
0 => string '2'
'id' => string '2'
1 => string 'record two'
'name' => string 'record two'
我该怎么做才能将以上内容转化为以下内容?
what should I do to turn the above into the following?
array
0 =>
array
'id' => string '1'
'name' => string 'record one'
1 =>
array
'id' => string '2'
'name' => string 'record two'
推荐答案
不要使用 mysql_fetch_array()
.使用 mysql_fetch_assoc()
. (或Mysqli等效项)
Don't use mysql_fetch_array()
. Use mysql_fetch_assoc()
. (Or the Mysqli equivalents)
这篇关于删除php-mysql结果行中的重复字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文