Hi,

I wrote a method in a php class a few years back for calculating the distance between UK postcodes which worked by calculating the distance between grid reference points (northings and eastings), which I had stored in a database.

With a bit of tweaking you could use this function to do what you need. However, you'll have to find someway of converting lat/long co-ordinates to grid references, you're on your own here so I advise you search google code as it may be done already.

It's funny, this brings me back to my school days when we were doing trigonometry in Maths, and I said to my teacher: "Why would I want to know where a tree is going to fall when its cut, I've no interest in becoming a lumberjack!".

So low and behold I got my first lesson in Latin maths, enter Pythagoras with his 'theorem' and the famous 'hypotenuse'!

Anyway, sorry for going off in a tangent, it just instantly made me think of that day in school!

PHP:

```
function calcDistance($easting1,$northing1,$easting2,$northing2)
{
// Calculate the northing and easting distance
$northingDistance=$northing1-$northing2;
$eastingDistance=$easting1-$easting2;
// Calculate the distance between the two points (Pythagoras' Theorem)
$hypotenuse=sqrt(($northingDistance*$northingDistance)+($eastingDistance*$eastingDistance));
$kms = round($hypotenuse/1000,2);
$miles = $kms * .62;
return $miles;
}
```