baikho / belgian-address-parser-php
A Belgian address parser library in PHP
v1.0.2
2025-03-25 20:23 UTC
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-03-25 20:48:54 UTC
README
A Belgian address parser library in PHP.
Requirements
- PHP 8.1 or higher
Installation
You can install the package via composer:
composer require baikho/belgian-address-parser-php
Usage
// 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;