Find country by knowing city name?

I have pages that show city names like:

“meet people in new york”

How can I out put the country name knowing the city?

either you have a mapping of cities to countries (e.g. in a database) or you query a geolocation service. although both variants can result in more than one country per city. e.g. the city named “Berlin” exists in 12 different countries.

You can’t easily. There are over a dozen places in the world named London, 10 in the USA, 1 in Canada, 1 in France - oh and one in England. So you really need to specify which one you’re referring to.

You would need a database of cities which includes a unique ID key as well as County and possibly state/county/region to be sure which city of that name is the right one.
That is if your data will contains cities with duplicate names, it may not be that big.

Thanks yo all guys well guess have to do it the hard way!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.