user3838972
user3838972

Reputation: 331

PHP Can't get value from multidimensional array

I can't echo $graphObject['location']['name'] from this array:

array(6) {
  ["birthday"]=>
  string(10) "09/09/1989"
  ["location"]=>
  object(stdClass)#8 (2) {
    ["id"]=>
    string(15) "110526485641433"
    ["name"]=>
    string(17) "Augsburg, Germany"
  }
  ["locale"]=>
  string(5) "de_DE"
  ["timezone"]=>
  int(2)
  ["updated_time"]=>
  string(24) "2014-06-20T08:24:24+0000"
  ["verified"]=>
  bool(true)
}

How to do that right?

Upvotes: 0

Views: 579

Answers (2)

Alex
Alex

Reputation: 1

echo $graphObject['location']->name;

Upvotes: 0

Gonzalo De-Spirito
Gonzalo De-Spirito

Reputation: 306

The $graphObject['location'] is not an array.

You can check that it says ["location"]=>object(stdClass).

It's and stdClass Object, so you can fetch the variable like this:

$graphObject['location']->name;

That's all.

Upvotes: 2

Related Questions