我从Google API获取了一个JSON代码,该代码显示两个车之间的距离和时间。从php数组获取价值(使用JSON创建)
With json_decode
我在PHP中创建了一个数组。
这是我使用print_r
时获取数组:
Array
(
[destination_addresses] => Array
(
[0] => Rachelsmolen 1, 5612 MA Eindhoven, Netherlands
)
[origin_addresses] => Array
(
[0] => Rachelsmolen 1, 5612 MA Eindhoven, Netherlands
)
[rows] => Array
(
[0] => Array
(
[elements] => Array
(
[0] => Array
(
[distance] => Array
(
[text] => 1 m
[value] => 0
)
[duration] => Array
(
[text] => 1 min
[value] => 0
)
[status] => OK
)
)
)
)
[status] => OK
)
我怎么能呼应 “1 M”([distance] => Array
下)在我的PHP代码?
---编辑--- 这是给我上面TE数组的代码:如果你想要静态
$link = "https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=" . $latitudeStart . "," . $longitudeStart . "&destinations=" . $latitudeStop . "," . $longitudeStop . "&key=MyGoogleApiKey";
$json = file_get_contents($link);
$data = json_decode($json, TRUE);
echo "<pre>"; print_r($data); echo "</pre>";
可以显示你的努力,直到现在(你的PHP代码)? –
请用您的密码编辑您的问题。 –
现在加入它,但哈桑的作品的答案。 – Stefan