Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $load_url='https://geocode-maps.yandex.ru/1.x/?geocode='.urlencode($city_name).'&format=json&results=1000';
- //echo $load_url;
- if ($file=get_url_from_yandex($load_url, $count=1))
- {
- $json=json_decode($file);
- if (isset($json->response->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->found)&&
- ($json->response->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->found!=0))
- {
- $json=$json->response->GeoObjectCollection->featureMember;
- $array_city_data=Array();
- foreach ($json AS $key=>$value)
- {
- if ($city_array=get_city_data_from_geo_object($value))
- {
- $array_city_data[]=$city_array;
- }
- }
- $new=Array();
- foreach ($array_city_data AS $value)
- {
- if (!in_array($value, $new))
- {
- $new[]=$value;
- }
- }
- unset($array_city_data);
- $array_city_data=$new;
- if (count($array_city_data)!=0)
- {
- return $array_city_data;
- } else {
- $error_message = 'No one locality with name "'.$city_name.'"!';
- return false;
- }
- } else {
- $error_message = 'Can`t find locality "'.$city_name.'"!';
- return false;
- //LOG
- }
- } else {
- $error_message = '123';
- return false;
- //LOG
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement