What's Here?
- Members: 99,781
- Replies: 389,609
- Topics: 58,611
- Snippets: 2,047
- Tutorials: 550
- Total Online: 1,534
- Members: 51
- Guests: 1,483
Who's Online?
|
Welcome to Dream.In.Code |
|
|
Getting PHP Help is Easy!
Join 99,781 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,534 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
|
This is a snippet for calculating the distance between 2 points. Each "point" is represented by the longitude & latitude for that location
|
Submitted By: PsychoCoder
|
|
|
Rating:
|
|
Views: 211 |
Language: PHP
|
|
Last Modified: May 14, 2008 |
|
Instructions: Pass the function the longitude/latitude for each location and a type (M for miles, K for kilometers) |
Snippet
function CalculateDistance($lat1, $lon1, $lat2, $lon2, $distanceType)
{
$theta = $lon1 - $lon2;
$miles = $dist * 60 * 1.1515;
if ($distanceType == "K")
{
//return distance in kilometers
return ($miles * 1.609344);
}
else
{
//return distance in miles
return $miles;
}
}
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|