Fw: [PHP] Distance Based on Zip Code

From: Date: Mon, 18 Nov 2002 23:03:25 +0000
Subject: Fw: [PHP] Distance Based on Zip Code
Groups: php.general 
Request: Send a blank email to php-general+get-124993@lists.php.net to get a copy of this message
// 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" <vernon@comp-wiz.com> To: <php-general@lists.php.net> 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 > >

« previous php.general (#124993) next »