每次我运行 mysql_fetch_array 时,都会返回一个包含重复值的数组例如
Array
(
[0] => 1
[row_id] => 1
[1] => some text
[first_field] => some text
[2] => some text
[second_field] => some text
}
但我只想要数组中的单个结果,我试过使用
mysql_fetch_array($data, MYSQL_ASSOC);
但这没有什么区别。
最佳答案
这是 mysql_fetch_array()
的预期功能.如果你不想有“重复项”而只想有关联数组,请使用 mysql_fetch_assoc()
相反。
例子:
while ($row = mysql_fetch_assoc($data)) { ... }
关于php - mysql_fetch_array 返回重复数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11957541/