从Google MAP API Curl请求获取City state zip

时间:2017-06-22 10:37:29

标签: php google-maps curl google-maps-api-3

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

我想从Google API返回的地址中获取citystatezipcode

现在我必须从以下字符串中爆炸

"formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",

1 个答案:

答案 0 :(得分:4)

您可以使用array_filter过滤每个address_components的{​​{1}}字段:

types