<?php
$name = urlencode( 'Manchester, UK' );
$baseUrl = 'http://nominatim.openstreetmap.org/search?format=json&q=';
$data = file_get_contents( "{$baseUrl}{$name}&limit=1&addressdetails=1" );
foreach ( json_decode( $data ) as $elem )
{
printf( "%s, %s @ %.3f, %.3f\n",
$elem->address->city, $elem->address->country,
$elem->lat, $elem->lon
);
print_r( $elem );
}
?>
Output
http://wiki.openstreetmap.org/wiki/Nominatim