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.
I originally posted this as a comment, but since it indeed was the answer to the question…
If you have a totally WTF error:
Change the error message and run the program again. If it shows the original error message, you are running a different file than you are editing (e.g. not uploading, wrong directory) or have another copy of the error-message generating code somewhere.
Check your files for unprintable characters using an editor that shows them
No. 1 is one of the most common reasons for unexplainable errors.