Home > OS >  How do I get sample values - Uncaught Error: Cannot use object of type stdClass as array
How do I get sample values - Uncaught Error: Cannot use object of type stdClass as array

Time:04-30

I print this array with var_export(), How do I get sample values of "id", "username", "password", "livello" etc

array (
  'iss' => 'miosito.com',
  'aud' => 'loginutente',
  'iat' => 1651245629,
  'nbf' => 1651245639,
  'exp' => 1651288829,
  'data' => 
  (object) array(
     'id' => '6',
     'username' => 'testuser',
     'password' => 'xxxxxxx',
     'livello' => '1',
  ),
)

CodePudding user response:

You are accessing an object from within an array so $arr['data']->id

CodePudding user response:

Since you converted the data array to an object, you can access the values like this

echo $array['data']->id;
echo $array['data']->username;
...
  • Related