0

So I have an in_array check, called

if (in_array('pageLevel',$userlevels))

Which I want to connect to a boolean, like $hasAccess so I can apply

if ($hasAccess == true) { do something }

I tried if (in_array('pageLevel',$userlevels)) { $hasAccess == true }

but that does not seem to work. Can anyone tell me how to use this?

0

2 Answers 2

3

$hasAccess == true

Should be $hasAccess = true. Or

$hasAccess = in_array('pageLevel',$userlevels);
Sign up to request clarification or add additional context in comments.

1 Comment

if (in_array('pageLevel',$userlevels)) { $hasAccess = true; } if ($hasAccess) { dosomething } works like a charm! Thanks guys, I was indeed mixing up the operators.
1

Try $hasAccess = true; You need to assign to the variable (=), rather than just compare it (==) and throw the result away.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.