簡體   English   中英

數組差分比較多個數組列表

[英]Array differential compare multple array list

如何比較數組差異中的3個或更多數組列表? 我使用此代碼,但似乎只有2個數組在比較。 我做錯什么了嗎?

$purchaseorderinventory=mysqli_query($link,"select * from purchaseorder where ITEM_CODE_MX='".$value."' and SHIP_TO_MX='".$display_branchcode."' and STATUS_PO_MX='RECEIVED'");
    while($row3=mysqli_fetch_array($purchaseorderinventory))
                                    {
                                  $imeipo[]=$row3["IMEI_MX"];


            }
                        $implodepo = implode(",",$imeipo);
                        $explodepo = explode(',', $implodepo);

    $beginventory=mysqli_query($link,"select * from inventory where ITEM_CODE_MX='".$value."' and BRANCH_CODE_MX='".$display_branchcode."'");
    while($row=mysqli_fetch_array($beginventory))
                                    {

                                    $cid=$row["ID_INVENTORY"];
                                     $itemcode=$row["ITEM_CODE_MX"];
                                     $itemquantity=$row["ITEM_QUANTITY_MX"];
                                     $imei=$row["IMEI_MX"];
                                     $site=$row["SITE_CODE_MX"];
                                    $begexplode = explode(',', $imei);


                                    }
    $transfer=mysqli_query($link,"select * from transferinventory where ITEM_CODE_MX='".$value."' and SITE_FROM_MX='".$display_branchcode."'");
    while($row2=mysqli_fetch_array($transfer))
                                    {


         $imeitransfer[]=$row2["IMEI_MX"];


                        }

                        $implodeimeitransfer = implode(",",$imeitransfer);
                        $transferexplode = explode(',', $implodeimeitransfer);
                        //diffrence
        $inventorydiff = array_diff($transferexplode,$explodepo,$begexplode);

                        $finalimplode = implode(",",$inventorydiff);

比較並檢查返回的數組的大小是否為零。 如果為零,則意味着所有3個均相等。

if(empty(array_diff($array1, $array2, $array2))){
 echo "All three are equal";
}
else
  echo "they are not not equal";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM