I have 2 array, the value will be from database, below is the case example:
$arr1 = array(1,2,3);
$arr2 = array(1,2,3,4,5,6,7);
What I want to do is to check if all values in $arr1
is exist in $arr2
. the above example should be a TRUE
while:
$arr3 = array(1,2,4,5,6,7);
comparing $arr1
with $arr3
will return a FALSE
.
Normally I use in_array
because I only need to check single value into an array. But in this case, in_array
cannot be used. I'd like to see if there are any simple way to do the checking with a minimum looping.
UPDATE for clarification.
First array will be a set that contain unique values. Second array can contains duplicated values. Both is guaranteed an array before processed.
TIA