php
  • arrays
  • 2016-08-10 19 views 0 likes 
    0

    配列差分で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); 
    

    答えて

    0

    返される配列のサイズがゼロかどうかを比較して確認します。 0の場合、3はすべて等しいことを意味します。

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

    これらは等しくない –

    関連する問題