我只想将 Google Maps API 距离矩阵的输出转换为 PHP 以进行进一步处理。我不知道如何将距离值返回到变量中。我的数据是来自 Google Maps API v3 的 JSON 文件。
{
"destination_addresses" : [ "San Francisco, Californie, États-Unis", "Victoria, BC, Canada" ],
"origin_addresses" : [ "Vancouver, BC, Canada", "Seattle, Washington, États-Unis" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "1 703 km",
"value" : 1703343
},
"duration" : {
"text" : "3 jours 19 heures",
"value" : 326836
},
"status" : "OK"
},
{
"distance" : {
"text" : "138 km",
"value" : 138267
},
"duration" : {
"text" : "6 heures 45 minutes",
"value" : 24278
},
"status" : "OK"
}
]
},
{
"elements" : [
{
"distance" : {
"text" : "1 451 km",
"value" : 1451182
},
"duration" : {
"text" : "3 jours 4 heures",
"value" : 274967
},
"status" : "OK"
},
{
"distance" : {
"text" : "146 km",
"value" : 146496
},
"duration" : {
"text" : "2 heures 52 minutes",
"value" : 10321
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
我是 javascript 和 JSON 的新手,PHP 经验很少。