dqbhdsec59405 2013-06-18 12:06
浏览 29

PHP Array将两个键控数组合并为一个数组

I am two arrays both containning 4 keyed values. They both have the same columns - how would I merge them like so:

Array 1:

Author|Download|Rating|Count
person|23      | 5    | 0
peter |45      | 4    | 0

Array 2:

Author|Download|Rating|Count
      | 0      |0     | 3
      | 0      |0     | 5

Becomes a single array:

Author|Download|Rating|Count
person|23      | 5    | 3
peter |45      | 4    | 5

This is done via two SQL Queries like shown:

Array 1

 while ($stmt->fetch()) 
        {
            $array = array (
                    'Author' => $author,
                    'Download' => $download,
                    'Rating' => $rating,
                    'Count' => '',
                    );                  
        }   

Array 2

while ($stmt->fetch()) 
        {
            $array = array (
                    'Author' => '',
                    'Download' => '',
                    'Rating' => '',
                    'Count' => $count,
                    );                  
        }

How would I get these into a single Array? I know one could do this via loop but is there an easier way to do this?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端