JSONを解析する方法グーグルマップJSONをPHPで
私はxmlでそれを行っていますが、JSONで取得するように座標駆動方向が完全ではありません。phpでJSONを使用してすべての座標駆動を取得するにはどうすればよいですか?
xmlを使用する場合
$xml = simplexml_load_file('http://maps.googleapis.com/maps/api/directions/xml?origin='.$origin.'&destination='.$dest.'&sensor=false');
$startlat = $xml->xpath("/DirectionsResponse/route/leg/step/start_location/lat");
$startlng = $xml->xpath("/DirectionsResponse/route/leg/step/start_location/lng");
$distanceeach = $xml->xpath("/DirectionsResponse/route/leg/step/distance/value");
$distance = $xml->xpath("/DirectionsResponse/route/leg/distance/value");
しかし、jsonをどうするか?xmlを使用する場合、変数$ startlat、$startlngなどに同じ値が含まれるようにします