$access = array('a', 'c', 'h', 'r', 'r');
$admin = array('e', 'q');
function check_access($username, $adminonly = false) {
global $access, $admin;
if (in_array($username, $admin)) {
return true;
}
if (!($adminonly) && in_array($username, $access)) {
return true;
}
return false;
}
echo check_access('r') ? 'is' : 'is NOT' ," allowed.";
echo check_access('q') ? 'is' : 'is NOT' ," allowed.";
echo check_access('r', true) ? 'is' : 'is NOT' ," an admin.";
echo check_access('q', true) ? 'is' : 'is NOT' ," an admin.";
?>