check multiple values exists php array

arrays, php

Solution

Use `array_intersect`

count(array_intersect($permission, $userRoles));

Problem

I have an array in PHP ``` $permission = array( "admin", "moderator", "guest" ); ``` and i have another array ``` $userRoles = array( "admin", "moderator" ); ``` I checked with `in_array` but it doesn't work with multiple values. How can i check atleast one value in `$userRoles` exists on `$permission` without looping ? Thanks in advance.

Original source