我只是想输出渥太华输入酒店的格式化地址。结果给了我我需要的所有数据以及不需要的东西。我需要截断这个。有任何想法吗?
$address = urlencode("Hotels, in Ottawa");
$geocodeURL = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=hotels+in+Ottawa&sensor=false&key=mykey";
$ch = curl_init($geocodeURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$geocode = json_decode($result);
echo $result;
//echo $formatted_address = $geocode->data[0]->formatted_address;