0

I have a two array's like below:

$arr = ["sample","sample2","sample3"];
$arr1 = ["sample3","sample2","sample"];

If you notice the above two arrays having same values but in different positions.

I want to check if these two arrays are qual or not ?

I have a below solution but looking for best solution.

var_dump((count($arr) == count($arr1) && !array_diff($arr, $arr1)));

Please help me with accurate solutions. Thanks !

Vasu Kuncham
  • 528
  • 3
  • 14

1 Answers1

-1

The only I can think out of the top of my head is.

if(  count(array_diff($arr,$arr1)) ){
   print "Array is different";
}else{
   print "Array is the same";

Hope it can be of some help.

Vidal
  • 2,605
  • 2
  • 16
  • 32