PHP code example of davidvandertuijn / geodistance

1. Go to this page and download the library: Download davidvandertuijn/geodistance 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/ */

    

davidvandertuijn / geodistance example snippets


use Davidvandertuijn\Geodistance;

// Rotterdam
$lat1 = 51.924419;
$lon1 = 4.47917;

// Amsterdam
$lat2 = 52.370216;
$lon2 = 4.477733;

Geodistance::distance($lat1, $lon1, $lat2, $lon2, 'M'); // 30.800174981173

Geodistance::distance($lat1, $lon1, $lat2, $lon2, 'K'); // 49.568076804901

Geodistance::distance($lat1, $lon1, $lat2, $lon2, 'N'); // 26.746871953651