私はJSON要素
JSONは
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "Narayan Peth, Pune, Maharashtra 411030, India",
"geometry" : {
"location" : {
"lat" : 18.515797,
"lng" : 73.852335
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "3a25975b3806df28aa79ac4a8d954c307be4aa57",
"name" : "Aditya Medical",
"place_id" : "ChIJJxwmOHDAwjsRjRDO4LnGJ-I",
"reference" : "CmRSAAAA3E7ih55-2BZjRQcw_URQ2gwi8eWb5HU6hdfNUj_TqtDJ7TtASVMowcuWMkohNjp7F6UKuGsMuR-IlzZEt4YUJyzNxzWg-TYy6hyN8P5n2asAO6ztZeU3oHZdH7OBFFW_EhBe4cQbAU99oILcDmvv_gOhGhR7jzP0Z9-mDrncd5Gr9hOY7aOqRg",
"types" : [ "pharmacy", "health", "store", "point_of_interest", "establishment" ]
}
],
"status" : "OK"
}
私は疲れて使用して印刷することJSONから「formatted_address」要素を印刷したい1つのJSONを持っていますが、にアクセスするためにどのようにそれを印刷することができませんでし。 object
又はarray
-
foreach (json_decode($address[0]->Response) as $obj){
print_r($obj['results']['formatted_address']);
}
$ obj'最初 – Regolith
彼らはオブジェクトではなく配列している '印刷してみてください。 'json_decode'の2番目のパラメータとして' true'を渡して配列を取得するか、オブジェクトをオブジェクトとして使用してください。 –