This is what I have:
$distance = number_format(ceil(69*rad2deg(acos(sin(deg2rad($ulat)) *
sin(deg2rad($vlat)) + cos(deg2rad($ulat)) * cos(deg2rad($vlat)) *
cos(deg2rad($ulong - $vlong))))));
where:
$ulat = latitude of user #1
$ulong = longitude of user #1
$vlat = latitude of user #2
$vlong = longitude of user #2
it seems to work properly at least with US data. I assume any
longitude/latitude date will work fine with it. If anyone has links to
other countries' zipcode mappings I'd love to be able to add that to
my site :)
(I basically took a MySQL query and mapped it to the PHP functions)
On 9/1/08, Tom Chubb <[EMAIL PROTECTED]> wrote:
> > <snip>
> > public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
> > false)
> > {
> > $multiplier = 6371;
> > if ($blnMiles)
> > $multiplier *= 1.609344;
> >
> > $rv = <<<ESQL
> > (ACOS(
> > SIN(RADIANS($latA)) * SIN(RADIANS($latB))
> > + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
> > RADIANS($lngA)))
> > * $multiplier)
> > ESQL;
> > return $rv;
> > }
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php