json - Get variable from PHP Session array with Curly Braces -


i have command line:

echo $_session['info']; 

it outputs exact array curly braces included:

{"_var1":"user","_var2":"password"} 

how information these variables? output 'user' i've tried:

echo $_session['info']['_var1']; 

but doesn't output anything.

that's json. values need use json_decode():

$info = json_decode($_session['info'], true); echo $info['_var1'];  // user 

the above example gives array since question using them. can object:

$info = json_decode($_session['info']); echo $info->_var1;  // user 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -