Reputation: 13
It seems like there would be a shorter way of writing this:
if ($action == 'add' || $action == 'update' || $action == 'delete') {
// whatever
}
is there?
Upvotes: 1
Views: 58
Reputation: 275
I prefer this form, since it is easier to maintain:
if(in_array($action, array('add', 'update', 'delete'))) {
}
Upvotes: 1
Reputation: 14946
if (in_array($action, array('add', 'update', 'delete'))) {
// whatever
}
Upvotes: 4