0

I know this question has been asked before. but whenever I try to get the value of my array it does not work, only difference I can see is the name of a value is a number?

$returnValue = json_decode('{"content": [{"id": 1249029}]}');`

That gives me an array that looks like:

stdClass::__set_state(array(
   'content' => 
  array (
    0 => 
    stdClass::__set_state(array(
       'id' => 1249029,
    )),
  ),
))

So getting my id should be as simple as:

var_dump($returnValue['content']->0->id);

This code gives me an error 500.

Thanks,

JSChasle
  • 45
  • 8

1 Answers1

0

You need to access it like this:

$returnValue->content[0]->id;
Esteban Garcia
  • 2,171
  • 16
  • 24