Just recently I needed a mysql database table that contained records for city, state, zip, latitude, and longitude coordinates. I needed a complete list of locations since one of my projects involved an ajax location auto populating script. While browsing on the web to find a free solution, I finally found a complete list of US zip codes from 2006 that contained everything that I wanted. I downloaded the files and realized it was written in Perl by R. Don Henning. I rewrote it in PHP for developers looking for a PHP solution.
Simply Download the files and place the directory wherever you would like. Make sure to edit the zip_insert.php file and change the database connection with yours.
Version 3 Updates:
Replaced file_get_contents with file so we return an array of each line. Replaced for loop with foreach loop. Removed the split function that is deprecated as of PHP 5.3.
Version 2 Updates:
There was an issue with leading zeros not being inserted into the database. I have added zerofill and changed INT(5). This is fixed now!