Hmm, somehow I managed to post my response before I was done...
I think what you're trying to do is a binary AND
ie. index(15) & Level4(8) = 1 access granted
the following should accomplish what you want:
if ($page_value & $user_value)
{
user can access page
}
else
{
user cannot access page
}
I use something similar as the base for a user rights system where various rights are assigned a value as a power of 2(login = 1, post message = 2, admin = 4, etc.) and the user's rights (login + admin for example -> 5) are added up and stored as an integer in the user's database entry. Any page requiring a specific right for access performs an if($access_right & $users_rights_value) and redirects back to a common index page if a false value is returned. Does that make sense?