// Function takes latitude and longitude  of two places as input
// and prints the distance in miles and kms.
function calculateDistance($lat1, $lon1, $lat2, $lon2)
    // Convert all the degrees to radians
    $lat1 = deg2rad($lat1);
    $lon1 = deg2rad($lon1);
    $lat2 = deg2rad($lat2);
    $lon2 = deg2rad($lon2);

    // Find the deltas
    $delta_lat = $lat2 - $lat1;
    $delta_lon = $lon2 - $lon1;

    // Find the Great Circle distance
    $temp = pow(sin($delta_lat / 2.0), 2) + cos($lat1) * cos($lat2) *
pow(sin($delta_lon / 2.0), 2);

    $EARTH_RADIUS = 3956;

    $distance = ($EARTH_RADIUS * 2 * atan2(sqrt($temp), sqrt(1 - $temp)) *
1.6093);

    return $distance;
}


Register your Domain for as little as $8.95 yr.
At pgaws.com

Find a contractor or find a contract at Tech-Temp.com

----- Original Message -----
From: "vernon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 18, 2002 3:21 PM
Subject: [PHP] Distance Based on Zip Code


> Does anyone know how I can set something up that tells the distance
between
> one Zip Code and another? I'm needing to be able to set something up where
> one user's record is compared to another and a distance is measured. Any
> have any ideas?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to