WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Latitude-Longitude to Miles
Categories : PHP, Utilities, Math. Update Picture
Farrukh Shahzad
Date : Feb 14th 2001
Grade : 1 of 5 (graded 1 times)
Viewed : 5299
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Farrukh Shahzad
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

/* Author: Farrukh Shahzad */
// This function was originally written by R.V. as
// shown on the algorithm section of code gallery (http://www.zend.com/codex.php?
id=32&single=1).
// I tried that function and found that it is not given the same answer (I dont know whether
Raplh's math is right)
// as given by my function shown below.
//Also It is much simpler math and gives direction of 2nd point with respect first

function calcMiles($lat1, $lon1, $lat2, $lon2) {

$deg2mile = 69.09; //for earth
$temp1 = cos(deg2rad($lat1));
$temp2 = cos(deg2rad($lat2));

$dist = sqrt( $temp1 * $temp2 * pow($lon1 - $lon2 , 2) + pow($lat1 - $lat2, 2) );
$miles = $dist * $deg2mile;

if ($lat2 == $lat1){
if ($lon2 == $lon1)
$dirstr="";
else {
if($lon2 > $lon1)
$dirstr = "East";
else
$dirstr = "West";
}
}else if($lat2 < $lat1){
if($lon2 == $lon1)
$dirstr="North";
else {
if($lon2 > $lon1)
$dirstr="NorthEast";
else
$dirstr="NorthWest";
}
}else if ($lat2 > $lat1){
if($lon2 == $lon1)
$dirstr="South";
else {
if($lon2 > $lon1)
$dirstr="SouthEast";
else $dirstr="SouthWest";
}
}

$miles = sprintf("%0.2f miles %s",$miles,$dirstr);
return $miles;
}



Math operations on big numbers
Categories : PHP, Math.
Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other?
Categories : PHP, Math., Arrays
mediaCat-GTK v2.0.0 - an mp3/cd/dvd cataloging utility written in php-gtk which interfaces with mysql and ms access (or db supported by PHP's Unified ODBC Functions)
Categories : PHP, MySQL, MS Access, Utilities, Databases
Diffusion-Limited Aggregation visualization
Categories : PHP, Graphics, Algorithms, Math.
Quote For the Day
Categories : PHP, Utilities, Filesystem
Monitor the files you provide for download! Track who downloads your files, and when.
Categories : PHP, Complete Programs, Utilities
decoct -- Decimal to octal
Categories : PHP, PHP Functions, Math.
How to judge if an integer is odd or is even in Php3?
Categories : Math., PHP, Algorithms
Temperature Conversion
Categories : PHP, Math., Beginner Guides
Contents Page - a script to build contents pages.
Categories : Complete Programs, PHP, Utilities, Filesystem
Show the steps for converting a number from a given base to base 10. Shows the steps involved in converting a number from a given base to base 10.
Categories : PHP, Math., Algorithms
Calculator for Baroque Violin strings
Categories : Math., PHP, Strings
grab directory listings into an array the example prints out each subdirectory in the main dir - further work is to be performed on this one
Categories : Filesystem, PHP, Directories, Search, Utilities
PHP-CSL PHP Code Snippet Library, A very handy application designed to save you many hours by storing all your code snippets, classes and functions.
Categories : PHP, Utilities, MySQL, Databases, To PHP
Easy to use random number function that seeds with uniqid and allows a max value
Categories : Math., PHP