需要从 Google Maps API 中获取值 "distance" "text",并将其转换为 PHP 字符串。
例如,https ://maps.googleapis.com/maps/api/distancematrix/json?origins=TN222AF&destinations=tn225dj&mode=bicycling&language=gb-FR&sensor=false&units=imperial给我们:
{
"destination_addresses" : [ "New Town, Uckfield, East Sussex TN22 5DJ, UK" ],
"origin_addresses" : [ "Maresfield, East Sussex TN22 2AF, UK" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "3.0 mi",
"value" : 4855
},
"duration" : {
"text" : "22 mins",
"value" : 1311
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
如何将值“3.0 mi”从这个 JSON 提要更改为 PHP 变量?
非常感谢!