0

I have the following JSON object:

[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
   0: Object
      category: Object
         0: "Value"

I was wondering how I could get 'Value' in a variable in PHP. I thought category[0] would just do it but I get the following instead of 'Value':

 __proto__: Object 

What should I do?

Anoniem Anoniem
  • 1,915
  • 6
  • 18
  • 19

1 Answers1

1

You have to converts the JSON string into associative array, which is done by json_decode() with second parameter set as true.

$var = json_decode($json, true); 
$value = $var['0']['category']['0'];
Ladislav M
  • 2,157
  • 4
  • 36
  • 52