0

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?

4
  • $graphObject['location']->['name'] ? Commented Jul 30, 2014 at 23:25
  • $graphObject['location']->{name} Commented Jul 30, 2014 at 23:26
  • $graphObject['location']=>['name'] or $graphObject['location']->['name'] isn't working Commented Jul 30, 2014 at 23:27
  • $graphObject['location']->{'name'}; worked thanks Commented Jul 30, 2014 at 23:29

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.