Here is an example of using PostGIS, spatial extensions for postgresql. Similar extensions exist for mysql, oracle, mssql, sqlite and, no doubt, other databases. PostGIS must be installed for this to work.
First you must convert the shapefile to sql file:
fmark@fmark-laptop :~$ shp2pgsql -c Desktop/zillow/ZillowNeighborhoods-AK.shp zillowak > Desktop/zillow/ZillowNeighborhoods-AK.sql Shapefile type: Polygon Postgis type: MULTIPOLYGON[2]
Then run sql in the database (the "gis" database in this case) to convert the sql file to a spatially resolved table:
fmark@fmark-laptop :~$ psql -d gis -f Desktop/zillow/ZillowNeighborhoods-AK.sql SET BEGIN ... COMMIT
At this point, you probably want to create a spatial index as you are going to make a spatial query:
fmark@fmark-laptop :~$ psql -d gis psql (8.4.2) Type "help" for help. gis=
Now, if you have lat / long (in this example -149.309W, 60.985S), you can find what area it is in: fmark @ fmark-laptop: ~ $ psql -d gis psql (8.4.2) Enter "help" for reference.
gis=# select gid, state, county, city, name, regionid from zillowak WHERE ST_CONTAINS(the_geom, GeomFromText('POINT(-149.309 60.985)', -1)); gid | state | county | city | name | regionid -----+-------+-----------+-----------+---------------+---------- 29 | AK | Anchorage | Anchorage | Turnagain Arm | 275783 (1 row) gis=# \q fmark@fmark-laptop :~$
This last step can obviously be made from PHP with a simple request.