Getting the role ID from the global $user
You can use array_key_exists() to do this:

$rid = 42;

if (array_key_exists($rid, $user-&gt;roles)) {
  // Do stuff
}


If you just want an array of RIDs, you can use array_keys():

$rids = array_keys($user-&gt;roles);