PHP code example of baikho / belgian-address-parser-php
1. Go to this page and download the library: Download baikho/belgian-address-parser-php 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/ */
baikho / belgian-address-parser-php example snippets
// Create a parser instance
$parser = new \Baikho\BelgianAddressParser\Parser();
// Parse an address
$parsed = $parser->parse('Andreas Vesaliusstraat 47, 3000 Leuven, België');
// Output the parsed components
print_r($parsed);
Array
(
[recipient] =>
[street] => Andreas Vesaliusstraat
[number] => 47
[box] =>
[postal_code] => 3000
[city] => Leuven
[country] => België
)
// Validate the address
$validation = $parser->validate($parsed);
if ($validation['valid']) {
echo "Address is valid!\n";
} else {
echo "Address has issues: " . implode(', ', $validation['errors']) . "\n";
}
// Format the address back to string
$formatted = $parser->format($parsed);
echo $formatted;