What's Here?
- Members: 109,545
- Replies: 414,438
- Topics: 63,021
- Snippets: 2,288
- Tutorials: 611
- Total Online: 1,178
- Members: 52
- Guests: 1,126
Who's Online?
|
Welcome to Dream.In.Code |
|
|
Getting PHP Help is Easy!
Join 109,545 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,178 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: 329 |
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
|