Region/City/State Grouping? (Selecting a certain city and getting the surrounding cities grouped in a X mile radius)

Trying to figure this one out. I want to group a metroplex by the cities surrounding XYZ city. Like Craigslist, if you select just Chicago, you get the results for the surrounding neighborhoods and close cities, too.

How would I go about this? I want to help narrow down search results, so if someone selects say Dallas, Texas, I want all cities and areas to show up within say a 15-30 mile radius by default within or even bordering the city of Dallas.
I thought about a secondary multidimensional array with all regions and cities within XYZ radius, but there has to be a free API solution SOMEWHERE to easier dev this, right?

Where would I even start to plan this out? (Maybe it’s just late, but I am genuinely lost here :man_facepalming:)

It’s not the api that’s difficult, it’s the data. I’ve written (but not in PHP) similar code but it requires a database of geo coordinates. In the code I wrote, I had a database of all the zipcode in the US and the lat/long of their approximate center. Armed with that I found/modified/wrote code that would give me all the customers in my list within 50 miles of Chicago.

In your case you would need cities/townships and their aprox lat/long center.

MaxMind - - might have a dataset you can work with. As far as I know they are the main source for this kind of data.