Check for multiple values in array


/ Published in: PHP
Save to your folder(s)

Drupal snippet


Copy this code and paste it in your HTML
  1. $needle = array (1, 'site administrator', 2, 'content manager');
  2.  
  3. $inside = false;
  4.  
  5. foreach ($needle as &$value)
  6. {
  7. if (in_array($value, array_values($user->roles)))
  8. {
  9. $inside = true;
  10. break;
  11. }
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.