PHP code example of popphp / pop-geo

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

    

popphp / pop-geo example snippets


use Pop\Geo\Geo;

$nola = new Geo();

echo $nola->getLatitude();  // 29.9546500
echo $nola->getLongitude(); // -90.0750700

$houston = new Geo([
    'latitude'  => 29.7632800,
    'longitude' => -95.3632700
]);

echo $nola->distanceTo($houston);          // Outputs '317.11' miles
echo $nola->distanceTo($houston, 2, true); // Outputs '510.34' kilometers

use Pop\Geo\Geo;

$nola = [
    'latitude'  => 29.9546500,
    'longitude' => -90.0750700
];

$houston = [
    'latitude'  => 29.7632800,
    'longitude' => -95.3632700
];

echo Geo::calculateDistance($nola, $houston); // Outputs '317.11' miles