PHP - Check if two arrays are equal

后端 未结 15 2154
说谎
说谎 2020-11-22 11:26

I\'d like to check if two arrays are equal. I mean: same size, same index, same values. How can I do that?

Using !== as suggested by a user, I expect th

15条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 11:58

    Compare them as other values:

    if($array_a == $array_b) {
      //they are the same
    }
    

    You can read about all array operators here: http://php.net/manual/en/language.operators.array.php Note for example that === also checks that the types and order of the elements in the arrays are the same.

提交回复
热议问题