<?php
$priorities = ["group.phantom", "group.god", "group.imperator", "group.general", "group.hermit", "group.soldier"];
$permissions = [
[
"permission" => "group.default"
],
[
"permission" => "group.phantom"
],
[
"permission" => "group.general"
]
];
$defaultPriority = 'group.default';
$defaultPriorityIndex = count($priorities);
$topPriorityIndex = $defaultPriorityIndex;
foreach ($permissions as $permission) {
$index = array_search($permission['permission'], $priorities);
if ($index !== false && $index < $topPriorityIndex) {
$topPriorityIndex = $index;
}
}
$topPriority = ($topPriorityIndex == $defaultPriorityIndex) ? $defaultPriority : $priorities[$topPriorityIndex];