0

is there any way to minimize/optimize the following if statement:

if($user->type == 'admin' || $user->type == 'manager' || $user->type == 'operator'){
  //do someting
}

Here, I am really tired of writing $user->type and || sign again and again. Besides, in somecase this types of logic unnacessarly longer.

Mizbah Ahsan
  • 1,252
  • 1
  • 8
  • 17

0 Answers0