我是两个数组,都包含 4 个键值。它们都有相同的列 - 我将如何合并它们:
阵列 1:
Author|Download|Rating|Count
person|23 | 5 | 0
peter |45 | 4 | 0
阵列 2:
Author|Download|Rating|Count
| 0 |0 | 3
| 0 |0 | 5
变成一个数组:
Author|Download|Rating|Count
person|23 | 5 | 3
peter |45 | 4 | 5
这是通过两个 SQL 查询完成的,如下所示:
阵列 1
while ($stmt->fetch())
{
$array = array (
'Author' => $author,
'Download' => $download,
'Rating' => $rating,
'Count' => '',
);
}
阵列 2
while ($stmt->fetch())
{
$array = array (
'Author' => '',
'Download' => '',
'Rating' => '',
'Count' => $count,
);
}
我如何将它们放入一个数组中?我知道可以通过循环来做到这一点,但有没有更简单的方法来做到这一点?