PHP Classes

PHP Distance between Two Coordinates: Get locations distance with longitude and latitude

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 424 All time: 6,367 This week: 77Up
Version License PHP version Categories
distance-calculate 1.0.0GNU General Publi...5.0PHP 5, Geography
Description 

Author

This class can get the distance between locations with given coordinates.

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

The distance value can be returned in miles, kilometers or nautical miles.

Picture of Vivek moyal
  Performance   Level  
Name: Vivek moyal is available for providing paid consulting. Contact Vivek moyal .
Classes: 7 packages by
Country: India India
Age: ???
All time rank: 35519 in India India
Week rank: 43 Up5 in India India Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
       
// $lat1= Your latitude, $lon1= Your Longitude, $lat2= Desired Latitude, $lon2= Desired Longitude
        // $unit can be blank too. If you need the results in Miles than leave it blank else.
        // Use K for kilometre and N for Nautical Miles
       
error_reporting(E_ALL & ~E_NOTICE & ~E_USER_NOTICE);
        include_once
'./calculateDistance.php';
       
$distanceClass=new calculateDistance();
       
$distanceClass->calculate($lat1, $lon1, $lat2, $lon2, $unit);
       
       
//For testing purpose uncomment the below line
       
echo $distanceClass->calculate("26.896623", "75.745167", "26.894555", "75.742460", "K");
   
       
?>
</body>
</html>


  Files folder image Files (2)  
File Role Description
Plain text file calculateDistance.php Class For calculating the distance of the given latitude and longitude
Accessible without login Plain text file index.php Example Example code for using the class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:424
This week:0
All time:6,367
This week:77Up
User Ratings User Comments (2)
 All time
Utility:87%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1308