jeudi 23 février 2017

Evaluate value of string as a condition and execute IF statement

I hope my title is not confusing. What I need is:

I have a condition in a string:

$user_rights = "$USER[ADMIN] || $USER[RIGHT1] || $USER[RIGHT2]";

var_dump($user_rights)

string(11) "0 || 0 || 0"

I would like to put the variable $user_rights into the IF statement like this

if($user_rights)

and I want it to work the same way like

if($USER[ADMIN] || $USER[RIGHT1] || $USER[RIGHT2])

Is it possible?

Aucun commentaire:

Enregistrer un commentaire