0

I'm trying to get isBeginWith function combine with OR (||) operand, it works but i want a neat code for this problem. I'm trying to make regex but not really sure. I want to combine with if in_array but I'm really confused. Here is it my code

$isBeginCreate = substr($permission->name, 0, strlen('create_')) === 'create_';
$isBeginRead = substr($permission->name, 0, strlen('read_')) === 'read_';
$isBeginUpdate = substr($permission->name, 0, strlen('update_')) === 'update_';
$isBeginDelete = substr($permission->name, 0, strlen('delete_')) === 'delete_';
$isBeginCrud = $isBeginCreate || $isBeginRead || $isBeginUpdate || $isBeginDelete; 

if($isBeginCrud){
// here my codes
}

Any suggestions?

Ray Coder
  • 620
  • 1
  • 9
  • 23

0 Answers0