check for multiple roles This code I use when checking if user has a role

if (in_array('administrator', array_values($user-&gt;roles)))


How to check for multiple roles? I tried something like this

if (!in_array('administrator', 'operator',  array_values($user-&gt;roles))


I made it work like this 

if (in_array('administrator', array_values($user-&gt;roles)) &amp;&amp; in_array('operator', array_values($user-&gt;roles)))


but there must be some less code solution.
but it is not working. Thank you.
Look at PHP's array_diff() function:

http://php.net/manual/en/function.array-diff.php

This will compare an array of the roles you're checking for against the array of the user's roles, and return an array containing the leftovers.

&lt;?php
$roles_to_check_for = array('administrator', 'operator');
$users_roles = array_values($user-&gt;roles);

if (array_diff($roles_to_check_for, $users_roles)) {
  // User does not have all of the $roles_to_check_for.
}
else {
  // User has all of the $roles_to_check_for.
}