GoogleAPIで、駅から目的地の時間を経度緯度から取得し、表示したのですが、英語で◯minと表示されてしまい、日本語に変換する方法をわかる方教えてください。
調べた所「json_encode( $res , JSON_UNESCAPED_UNICODE) ;」この記述を書けば日本語に出来るとあったのですがどういれたら良いのかわからず試行錯誤が続いています・・・
function get_station( $latitudet , $longitude , $station_latitude , $station_longitude ) { $res = array( 'distance', 'duration' ); $req = "https://maps.googleapis.com/maps/api/distancematrix/json?origins={$station_longitude},{$station_latitude}&destinations={$latitudet},{$longitude}&key=◯◯"; $json = file_get_contents($req); $decoded_json = json_decode( $json , true ) ; $res['distance'] = (string)$decoded_json['rows'][0]['elements'][0]['distance']['text']; $res['duration'] = (string)$decoded_json['rows'][0]['elements'][0]['duration']['text']; ; return $res; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。