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.
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.