Skip to content

Instantly share code, notes, and snippets.

@lftbrts
Created August 19, 2020 07:09
Show Gist options
  • Save lftbrts/62df1684561a67ddfc8d1284f45d2d4c to your computer and use it in GitHub Desktop.
Save lftbrts/62df1684561a67ddfc8d1284f45d2d4c to your computer and use it in GitHub Desktop.
simple hierarchy calculation
<?php
$hierarchy = [
'CUSTOMER_ADMIN',
'ADMIN',
'BUYER',
];
$currentRoles = [
'BUYER',
'ADMIN',
'IGNORE',
];
$highestRole = array_intersect($hierarchy, $currentRoles);
var_dump(reset($highestRole)); // output ADMIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment