duanhuang3074 2015-09-23 15:44
浏览 57

如何在PHP中比较两个pg_fetch_array结果?

I would like to compare values from two different database which are in two difference servers. So, I have queries in two different database and converted that to array using pg_fetch_array() function. I used array_diff() function but it is not giving expected result. The values in the each array will be like the following:

Array1=[[no=>100,quantity=>200,item=3353],no=>101,quantity=>20,item=3354]]
Array2=[[no=>100,quantity=>120,item=3353],no=>101,quantity=>20,item=3354],no=>1012,quantity=>20,item=3354]]

I should get response as: Array3=[[no=>100,quantity=>80,item=3353],no=>1012,quantity=>20,item=3354]]



<?php
    $row1 = pg_fetch_assoc($query1);
     $row2 = pg_fetch_assoc($query2);
    print_r($result);

    ?>

Please help me with a solution.

  • 写回答

1条回答 默认 最新

  • doumou5109 2015-09-23 15:52
    关注

    array_diff() is going to return the difference in the array, as described here. You are going to have do something where you iterate the arrays, compare, and then return the value you want.

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)