PHP code example of ici-brussels / bpost-addresses

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

    

ici-brussels / bpost-addresses example snippets


$bpost = new Bpost_Address_Validation();

// Find relevant address according to input
/* Option 1: Structured */
$bpost->getAddress_Structured("Rue de la loix", "15", null, 1000, "Bruxelles");
/* Option 2: Unstructured */
$bpost->getAddress_Unstructured("rue de la loi 15, 1000 bruxelles");

// get array with validated address
$result = $bpost->getStructuredAddress();
print_r($result);
/*
Array
(
    [StreetName] => Rue De La Loi
    [StreetNumber] => 15
    [BoxNumber] => 
    [PostalCode] => 1040
    [MunicipalityName] => Bruxelles
    [CountryName] => Belgique
)
*/

// get array with latitude/longitude
$result = $bpost->getGeographicalLocation();
print_r($result);
/*
Array
(
    [lat] => 50.845465
    [lon] => 4.369107
)
*/