PHP code example of filippo-toso / geodistance-php

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

    

filippo-toso / geodistance-php example snippets




unction Geodistance\centimeters;
use function Geodistance\feet;
use function Geodistance\kilometers;
use function Geodistance\miles;
use function Geodistance\meters;
use function Geodistance\yards;
use Geodistance\Location;

$new_york          = new Location(40.7128, 74.0059);
$los_angeles       = new Location(34.0522, 118.2437);
$decimal_precision = 3;

echo kilometers($new_york, $los_angeles); // 3936
echo miles($new_york, $los_angeles, $decimal_precision); // 2445.564
echo yards($new_york, $los_angeles); // 4304181
echo feet($new_york, $los_angeles); // 12912543
echo centimeters($new_york, $los_angeles); // 393575500
echo meters($new_york, $los_angeles); // 3935755

 bash
composer