これはphpにあります。配列に次の変数があります
Array ( [0] => { "name": "BRAVO Mario1050 [1] => Capital Federal [2] => Argentina" [3] => "Status": { "code": 200 [4] => "request": "geocode" } [5] => "Placemark": [ { "id": "p1" [6] => "address": "Buenos Aires [7] => Capital Federal [8] => Argentina" [9] => "AddressDetails": { "Accuracy" : 4 [10] => "Country" : { "AdministrativeArea" : { "AdministrativeAreaName" : "Capital Federal" [11] => "Locality" : { "LocalityName" : "Ciudad Autónoma de Buenos Aires" } } [12] => "CountryName" : "Argentina" [13] => "CountryNameCode" : "AR" } } [14] => "ExtendedData": { "LatLonBox": { "north": -34.5349161 [15] => "south": -34.6818539 [16] => "east": -58.2451019 [17] => "west": -58.5012207 } } [18] => "Point": { "coordinates": [ -58.3731613 [19] => -34.6084175 [20] => 0 ] } } ] } )
配列、爆発、および str_replace を使用して、-58.3731613、-34.6084175 を 2 つの変数に取得していますが、これを行う簡単な方法はありますか?
私がやったことは機能していましたが、どうやらグーグルが何かを変更したようです。なぜなら、1か月前とは異なる結果になったからです。質問は....グーグルが何かを変更した理由を誰か知っていますか?
すべてに感謝
念のため、以前は機能していた古いコード:
$longitude = "";
$latitude = "";
$precision = "";
//Three parts to the querystring: q is address, output is the format (
$key = "googlekey";
$address = urlencode(str_replace(',',' ',$calle).$altura.", ".$localidadList.", Argentina");
$url = "http://maps.google.com/maps/geo?q=".$address."&output=csv&key=".$key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$latitude= str_replace('Point','',$data[20]);
$latitude= str_replace('coordinates','',$latitude);
$latitude= str_replace('"','',$latitude);
$latitude= str_replace(':','',$latitude);
$latitude= str_replace('{','',$latitude);
$latitude= trim(str_replace('[','',$latitude));
$longitude= trim(str_replace('}','',str_replace('"west": ','',$data[21])));