Calculate distance with variable lat and lon values
Hi
I have a problem with implementing variables into a function that calculate distance between 2 latitudes, longitudes.
One of them is constant, and the second one being passed from the form.
////////// my way - return wrong calculation
echo distance("$lon1", "$lat1", 51.58734910, -0.30020239) . " miles<br>";
As long as i have lat, lon values hardcoded is fine, but idea is to have this calculation done from variables.
Both will vary .... tried different configurations ... i'm losing it ...
Looks like you have your latitude and longitude parameters transposed when you call your distance() function. (It's defined as lat, long, lat, long, but you've called it as long, lat, log, lat.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks