I want to compare two arrays in PHP

前端 未结 6 1758
萌比男神i
萌比男神i 2021-01-20 23:45

Assume that I have two arrays as follow:

$array1 = array(1, 3, 5);
$array2 = array(\'x\'=> 1, \'y\'=> 2, \'z\'=> 5);

How to check that

6条回答
  •  臣服心动
    2021-01-21 00:17

    like this:

     "green", "b" => "brown", "c" => "blue", "red");    
    $array2 = array ("a" => "green", "yellow", "red");    
    $result = array_diff($array1, $array2);    
    if(count($result) == 0)
    {
      .......  
    }    
    ?>
    

提交回复
热议问题