PHP code example of bektigalan / osm-address

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

    

bektigalan / osm-address example snippets




use Bektigalan\OsmAddress\Main;

// Initialize Main class
$geocoder = new Main();

// Example address
$address = 'Jalan Ahmad Yani Nganjuk';

// Get city
$city = $geocoder->getCity($address);
echo "City: $city\n";

// Get province
$province = $geocoder->getProvince($address);
echo "Province: $province\n";

// Get postal code
$postalCode = $geocoder->getPostalCode($address);
echo "Postal Code: $postalCode\n";

// Get full details
$details = $geocoder->getFullDetails($address);
print_r($details);