I googled and search StackOverflow many times an read the whole PHP manual for in_array()
but still stuck with what I thought it would be a very simple task.
So I have this array in my config.php file:
$page_access = array(
'index' => array('1', '2', '3'),
'users' => array('4', '5', '6')
);
In functions.php I have:
include 'config.php';
function level_access($page){
global $page_access;
if(in_array($page, $page_access)){
echo "yes";
} else {
echo "no";
}
}
level_access('index');
I expected to get "yes" as an output because then I would do something else in the function, but I'm stuck with a "no" output, no matter what I do.
I already tried a print_r($page_access)
INSIDE the function just to check if it can read the array, and IT DOES return me the whole array (which means the function is reaching the outside array), but every time the answer to in_array()
is NO.