PHP compare array

后端 未结 17 1773
萌比男神i
萌比男神i 2020-11-28 12:19

Is there anyway to compare arrays in php using an inbuilt function, short of doing some sort of loop?

$a1 = array(1,2,3);
$a2 = array(1,2,3);

if (array_are_         


        
17条回答
  •  春和景丽
    2020-11-28 13:08

    if(count($a1) == count($a2)){
        $result= array_intersect($a1, $a2);
        if(count($a1) == count($result))
            echo 'the same';
        else
            echo 'a1 different than a2';
    } else
            echo 'a1 different than a2';
    

提交回复
热议问题