rachel, mgm_03's question is just about looking for a cheaper solution in PHP... It's a fair question (better than a lot of them anyhow.)
mgm, the problem is that there is really a lot of work that goes into those types of things, because of the need for great circle math knowledge, and the proprietary maps developed and used by the services... (Think about the undertaking required to maintain those maps, and the info such as construction sites, speed traps, etc, required to keep the info current.)
You will be hard pressed to find free scripts, but the info is out there.... Just takes a lot of googling to find the info... Then a lot of PHP knowledge and skills to build it.
This forum posting/link has some info to help you get started on the types of things you need to know. Good luck with it.