PHP code example of phdevutils / geo

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

    

phdevutils / geo example snippets


use PhDevUtils\Geo\Geo;

Geo::findCoord('072217');            // ['name' => 'City of Cebu', 'lat' => 10.31, 'lng' => 123.89, ...]
Geo::findCoord('Cebu City');         // same — "City of X" / "X City" tolerant

Geo::distanceKm('133900', '072217'); // ~570.0  (Manila → Cebu, km)
Geo::distanceKm(['lat' => 14.6, 'lng' => 121.0], 'Makati'); // accepts raw lat/lng too

Geo::nearestCity('133900', 5);       // 5 nearest cities to Manila, nearest first (with 'distanceKm')
Geo::withinRadiusKm('133900', 30);   // every city/municipality within 30 km of Manila

Geo::listCoords(['region' => '07']); // all coordinates in Region VII (Central Visayas)