I fetched location:[] from monogodb and then encoded it in json and printed it on the screen. Here is the output:
{"57237036d89c45e1e3fda94e":{"_id":{"$id":"57237036d89c45e1e3fda94e"},"location":[33.7715,72.7511]}}
Now the problem is that I'm trying to get only location from this JSon so I decoded it. Here is the code:
echo $arr= json_encode(iterator_to_array($cursor));
$j= json_decode($arr,true);
var_dump( $j->location);
var_dump is returning null. Moreover it displays the following error
Trying to get property of non-object
PS: I know this question has been asked a lot of times but I couldn't find a solution.