Php 需要关于比较和合并两个阵列的帮助吗?
我有以下两个来自同一数据库的数组,它们使用相同的查询来获取这两个数组。两者都包含关于具有两个不同行项目(物料清单)的单个销售订单的信息。第一个具有行项目Php 需要关于比较和合并两个阵列的帮助吗?,php,arrays,multidimensional-array,Php,Arrays,Multidimensional Array,我有以下两个来自同一数据库的数组,它们使用相同的查询来获取这两个数组。两者都包含关于具有两个不同行项目(物料清单)的单个销售订单的信息。第一个具有行项目ItemID=600271,第二个具有行项目ItemID=600274,但正如您在下面看到的,它们都具有相同的销售订单编号[CustomerSONo]=>[7]=>**15020** 我遇到的困难:尝试使用内置函数,但我很难创建一个循环来比较和合并两者,然后将差异存储在单独的变量中 那么如何比较或合并这两个数组呢 //我想这样结束 Custo
ItemID=600271
,第二个具有行项目ItemID=600274
,但正如您在下面看到的,它们都具有相同的销售订单编号[CustomerSONo]=>[7]=>**15020**
我遇到的困难:尝试使用内置函数
,但我很难创建一个循环来比较和合并两者,然后将差异存储在单独的变量中
那么如何比较或合并这两个数组呢
//我想这样结束
Customer ID Customer_Bill_Name....... Item ID 1 Item ID 2
XXX001 XXX Company Name...... WH15 02 600278
//质疑
$result= --select statement--;
while($row = mysqli_fetch_array($result)) {
print_r($row);
}
//数组1
Array (
[0] => XXX001
[CustomerId] => XXX001
[1] => XXX Company Name.*
[Customer_Bill_Name] => XXX Company Name.*
[2] => DHE
[WhichShipVia] => DHE [3] =>
[INV_POSOOrderNumber] => [4] => 2014-12-19
[ShipByDate] => 2014-12-19 [5] =>
[GoodThruDate] => [6] =>
[CustomerSONo] => [7] => 15020
[Reference] => 15020 [8] => 2014-11-25
[TransactionDate] => 2014-11-25 [9] => 1
[DistNumber] => 1
[10] => 70.0000000000000000000 //here is the difference 1
[Quantity] => 70.0000000000000000000 //here is the difference 2
[11] => 600271 //here is the difference 3
[ItemId] => 600271 //here is the difference 4
[12] => ASSY7.60-15SL/8 FRM I1 15X6 6-6, BLK (GWT-761508 (24) //here is the difference 5
[SalesDescription] => ASSY7.60-15SL/8 FRM I1 15X6 6-6, BLK (GWT-761508)(24)//here is the difference 1 //here is the difference 6
[13] => AS1577 //here is the difference 7
[PartNumber] => AS1577 //here is the difference 8
[14] => ASSY7.60-15 8PLY W/WHL15X6 BLK //here is the difference 9
[ItemDescription] => ASSY7.60-15 8PLY W/WHL15X6 BLK )
//阵列2:
Array (
[0] => XXX001
[CustomerId] => XXX001
[1] => XXX Company Name.*
[Customer_Bill_Name] => XXX Company Name.*
[2] => DHE [WhichShipVia] => DHE [3] =>
[INV_POSOOrderNumber] => [4] => 2014-12-19
[ShipByDate] => 2014-12-19 [5] =>
[GoodThruDate] => [6] =>
[CustomerSONo] => [7] => 15020
[Reference] => 15020 [8] => 2014-11-25
[TransactionDate] => 2014-11-25 [9] => 2
[DistNumber] => 2
[10] => 6.0000000000000000000 //here is the difference 1
[Quantity] => 6.0000000000000000000 //here is the difference 2
[11] => 600274 //here is the difference 3
[ItemId] => 600274 //here is the difference 4
[12] => ASSY9.5L-15SL/8 FLT I1 15X8 6-6, BLK (GWT-951508)(16)
[SalesDescription] => ASSY9.5L-15SL/8 FLT I1 15X8 6-6, BLK (GWT-951508)(16) //here is the difference 5
[13] => AS1601 //here is the difference 6
[PartNumber] => AS1601 //here is the difference 7
[14] => ASSY9.5L-15 W/WHL15X8 6/6 BLK //here is the difference 8
[ItemDescription] => ASSY9.5L-15 W/WHL15X8 6/6 BLK ) //here is the difference 9
如果它们来自数据库并共享一个公共字段,那么为什么不首先使用
JOIN
ed查询呢?您能给出一个您期望的输出示例吗?