PHP Classes

PHP Distance Calculation using Latitude and Longitude: Calculate the distance between two world locations

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-03-05 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 122 This week: 1All time: 9,119 This week: 318Up
Version License PHP version Categories
distancecalculator 1.0The PHP License5PHP 5, Geography
Description Author

This class can calculate the distance between two world locations.

It can take the latitude and longitude coordinates of two locations in the worlds and calculates the distance between them.

The calculated distance can be returned as a string with the distance and optionally the distance unit in miles, kilometers, yards, meters and feets.

  Performance   Level  
Name: Tassadduq Hussain <contact>
Classes: 1 package by
Country: Pakistan Pakistan
Age: 33
All time rank: 421154 in Pakistan Pakistan
Week rank: 302 Up6 in Pakistan Pakistan Up




Calculate the distance between two points in Miles, Kilometers, Yards, Meters and Feets


//includee the class

//initiate class
$dc = new DistanceCalculator();

//latitude and logtitude of point 1
$dc->lat1 = 33.6437323;
$dc->long1 = 72.9585014;

//latitude and logtitude of point 2
$dc->lat2 = 33.6655587;
$dc->long2 = 73.0022321;

//define the unit of distance you want to get get data, default is 'miles'
$dc->type = 'km';

//choose if you want to display the selected unit type with the distance value, default is 'true'
$dc->show_type = false;

//calculate and get the distance
$distance = $dc->getDistance();

//show the calculated distance
echo $distance;
  Files folder image Files  
File Role Description
Plain text file DistanceCalculator.Class.php Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
This week:1
All time:9,119
This week:318Up

For more information send a message to info at phpclasses dot org.