PHP code example of igzard / php-geohash

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

    

igzard / php-geohash example snippets


use Igzard\Geohash\Geohash;

// Generate a geohash for a specific location with latitude and longitude coordinates.
echo Geohash::generate(47.497913, 19.040236); // input: Budapest coordinates | output: u2mw1q8xmssz

// Generate a geohash with custom precision (default is 12), latitude interval, and longitude interval.
echo Geohash::generate(47.497913, 19.040236, [
    'precision' => 10,
    'latitude_interval' => [
        'min' => -70,
        'max' => 10,
    ],
    'longitude_interval' => [
        'min' => -80,
        'max' => 170,
    ],
]);
bash
composer