PHP: How do I get an attribute from a JSON array?

后端 未结 3 1067
-上瘾入骨i
-上瘾入骨i 2021-01-15 16:24

I have the following JSON array:



        
3条回答
  •  死守一世寂寞
    2021-01-15 16:38

    You use json_decode.

    E.g.:

    $json_obj = json_decode($json);
    echo $json_obj->results[0]->geometry->location->lat;
    

    We access the first element of the results array, then navigate through the geometry, location, and lat properties. You can also make it use associative arrays, but the default is an object.

提交回复
热议问题