I'm currently playing around with a search algorithm for a small website I'm working on. My problem right now is, that it isn't flexible enough. My employer wants the search to be more flexible in a way it can search within cities as well.

Right now I have most of the search working, however I'm stuck with this city thing. What I want to do is to find a city name within the search string, get the city ID from the database and if the detected string actually is a city, the city name has to be removed from the original search string to do the specific search in titles and so on afterwards.

Eg. if I have the following search string "chiropractor copenhagen c" then I want to be able to find the "copenhagen c" part, get the city ID for this city and then exclude it from the rest of my search so that the rest only will search for "chiropractor".

I hope you understand what I am looking for.

Thanks