Daan Twice
Daan Twice

Reputation: 337

if condition of in_array to boolean

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?

Upvotes: 0

Views: 536

Answers (2)

Alexander Gessler
Alexander Gessler

Reputation: 46607

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

Upvotes: 1

Matthew
Matthew

Reputation: 48284

$hasAccess == true

Should be $hasAccess = true. Or

$hasAccess = in_array('pageLevel',$userlevels);

Upvotes: 3

Related Questions