如果两个数组中的任何元素匹配,则返回true? [重复]

This question already has an answer here:

I've two arrays, one is my define array and another I process from the database. Is there any proper way to compare between those arrays?

From database:

$user_type = [0 => "public" 1 => "10x413" 2 => "12x432"]

Defined array:

$specificUser = ['10x410','10x411','10x412','10x413','10x414'] 

If any element matches, then return true, just like php in_array() function.

</div>

Just loop and check as you would using in_array() to get the value that matches:

foreach($specificUser as $value) {
    if(in_array($value, $user_type)) {
        echo $value;
        //break; to stop checking, a match was found, or not to continue and see more
    }
}

Or to just test for any match:

if(array_intersect($specificUser, $user_type)) {
    // it's true :-)
}

I'm sure this has been asked and answered before, but here's a solution:

array() !== array_intersect($user_types, $specific_users);

Note: The array elements are compared using strict comparison, so two elements are considered matching only if they are the same type and value.