PHP code example of yrehan32 / php-haversine

1. Go to this page and download the library: Download yrehan32/php-haversine library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yrehan32 / php-haversine example snippets


use Yrehan32\PhpHaversine\Haversine;

/*
 * Calculate the distance between two points
 * @param float   $latitudeFrom   Latitude of the first point
 * @param float   $longitudeFrom  Longitude of the first point
 * @param float   $latitudeTo     Latitude of the second point
 * @param float   $longitudeTo    Longitude of the second point
 * @param string  $separators     Number of digits after the comma (default: 2)
 * 
 * @return float Distance between the two points
 */
$distance = Haversine::calculate(
    52.2296756,
    21.0122287,
    52.406374,
    16.9251681
);
echo $distance; // It will print 278.46
bash
composer