【发布时间】:2016-07-26 09:32:34
【问题描述】:
我在下面的数组上使用了 array_merge_recursive:
数组([111-23456-789] => 0 [2380600] => 1963 [8123123] => 0...)
数组([111-23456-789] => 0 [2380600] => 3860 [8123123] => 0...)
注意:因为 array_merge_recursive 作用于字符串键,所以上述数组的键实际上是另一个数组的字符串类型值。此外,数组实际上比这更大,因此数组的结束括号之前的“...”。
预期输出(根据我在 W3Schools.com 和 php.net 中的理解):
数组 ( [111-23456-789] => 数组 ( [0] => 0 [1] => 0 ) [2380600] => 数组 ( [0] => 1963 [1] => 3860 ) [ 8123123] => 数组 ( [0] => 0 [1] => 0 )...)
相反,我得到了这样的废话:
数组 ( [111-23456-789] => 数组 ( [0] => 0 [1] => 0 ) [0] => 1963 [1] => 0 [2] => 365... )
以下是我获得键数组的方法:
while ($nrows = mysqli_fetch_assoc($resultSetNames)) {
$name = $nrows['name'];
array_push($arrayNamesRes, "$name");
}
这就是我制作第一个关联数组的方式:
$nov = 0;
while ($novrows = mysqli_fetch_assoc($resultSetNov)) {
$counter = $novrows['count(playsms_tblsmsoutgoing.uid)'];
$arrayNovRes[$arrayNamesRes[$nov]] = $counter;
$nov++;
}
...和我的第二个关联数组:
$dec = 0;
while ($decrows = mysqli_fetch_assoc($resultSetDec)) {
$counter = $decrows['count(playsms_tblsmsoutgoing.uid)'];
$arrayDecRes[$arrayNamesRes[$dec]] = $counter;
$dec++;
}
我可以做些什么来获得预期的输出?我仍然是使用 stackoverflow 的新手。如果这篇文章太模糊,请说明。提前谢谢你。
【问题讨论】: