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
Post a Comment