Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created February 19, 2016 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d1i1m1o1n/61065ee393ad5b52212c to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/61065ee393ad5b52212c to your computer and use it in GitHub Desktop.
PHP: Get coordinates by address.
<?php
$adress = urlencode("Москва, Тверская улица, дом 7");
$url = "http://geocode-maps.yandex.ru/1.x/?geocode={$adress}";
$content = file_get_contents($url);
preg_match("/<pos>(.*?)<\/pos>/", $content, $point);
$coords = str_replace(' ', ', ', trim(strip_tags($point[1])));
echo $coords;
// результат: 38.241803, 56.300984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment