You will find this will be both a programmatic nightmare to maintain and a significant performance overhead to accomplish the task. You would likely find it much more effective (and less cumbersome) to work with lists instead. You could store these lists in a database, or even using a cloud service provider that communicates with a RESTful api and json.
An example, written in php (mostly pseudo code), assuming the permissions have already been retrieved from the data storage:
//user1 is logged in and has access to the following array of allowed pages:
$loggedInUserPerms = array(1,6,99,821,983255);
if (in_array($pageID, $loggedInUserPerms))
{
//the logged in user has access to this page
}
else
{
//the logged in user doesn't, display access denied error
}
You could even expand this principle and use multidimensional arrays:
$loggedInUserPerms = array(
1=>array("read"),
6=>array("read","write"),
9=>array("read","write"),
821=>array("read","write","delete"),
983255=>array("read")
);
if (in_array($pageID, $loggedInUserPerms))
{
//the logged in user has access to this page
//you can now handle the sub arrays as well
//to determine what level of access the user has.
}
else
{
//the logged in user doesn't, display access denied error
}