I have an array in PHP
$permission = array( \"admin\", \"moderator\", \"guest\" );
and i have another array
$userRoles = a
Use array_intersect
array_intersect — Computes the intersection of arrays
array
array_intersect ( array $array1 , array $array2 [, array $ ... ] )
array_intersect() returns an array containing all the values of array1 that are present in all the arguments. Note that keys are preserved.
Read
Use array_intersect
count(array_intersect($permission, $userRoles));