I have a snippet of code that looks like so:
if(array_key_exists('uid',$_SESSION)){
$userdata->readUser($_SESSION['uid']);
$ACL = new ACL($_SESSION['uid']);
$userPerms = $ACL->setACL();
if(!in_array_r("adminUI",$userPerms['perms'],true)){
echo "Couldnt fine adminUI in:";
var_dump($userPerms['perms']);
}
}
And the in_array_r function is:
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
Which I got from: in_array() and multidimensional array
However the output of this shows:
Couldnt fine adminUI in:
array(2) {
[0]=>
array(1) {
["perm_desc"]=>
string(7) "adminUI"
}
[1]=>
array(1) {
["perm_desc"]=>
string(9) "apiAccess"
}
}
If i change the function to check the array without STRICT it will find the needle, but FAILS on strict check...
I'm beating my head into the desk trying to figure this one out.
EDIT
Jan Schejbal was awesome enough to point out that this code works perfectly fine. I was not coherent enough to realize my working directory. Thank you again Jan Schejbal.