【发布时间】:2015-03-20 15:00:28
【问题描述】:
我有一个这样的数据库返回数组
$row['id']=1, $row['col1']='col1', $row['col2']=col2
当我将每个 $row 推送到 $result 时
array_push($result, $row);
$row 被覆盖 b/c 他们共享相同的密钥。我想不通。但如果它被覆盖,当我 var_dump($result) 时它应该只输出一组,而不是输出具有相同数据集的多行,请帮助。
【问题讨论】:
-
正如上面的代码所示,您将整个 $row 数组推送到 $result 数组...
-
您阅读手册了吗?
array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed.