I want to create something like permissions in my project. 
How do I check is string match one of the regex in array?

```php
//Array of user (group) permissions.
$arrayOfPermissions = [
    'admin.users.edit',
    'admin.users.*',
    'dashboard.view',

];

//Check is this permission presents in array
$stringToMatch = 'admin.users.view';

```

`*` sign mean that user have all permissions in this group.

For exemple:

If user have permission `admin.users.*` so he should pass validation for `admin.users.view`

**UPD:**
I use this now, but it looks like this is not good.

```php
private function checkPerms($permission)
{
    $arrayOfPermissions = [
        'admin.dashboard.view',
        'admin.users.*'

    ];

    foreach ($arrayOfPermissions as $perm)
    {
        if(preg_match("/".$perm."/", $permission))
        {
            return true;
        }
    }

    return false;
}

//This should return `true`
checkPerms("admin.users.view");

```

P.S. I use Laravel.