How to check two php arrays have one equal value -
this question has answer here:
i have very simple question , not found 1 in stack.
we have array :
array("1","2","3","4");
and
array("a","b","1","c");
the second array, have 1 value of first 1 , want have function checks 2 array , return true , if , there 1 or more 1 equal value in 2 arrays.
how can ?
like :
if(have_equal($array1,$array2)) { return true; }
you may try this:
if(array_intersect($array1, $array2)) { return true; } else { return false; }
check array_intersect
array_intersect() returns array containing values of array1 present in arguments. note keys preserved.
Comments
Post a Comment