PHP code example of awaisjameel / laravel-address-parser
1. Go to this page and download the library: Download awaisjameel/laravel-address-parser 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/ */
awaisjameel / laravel-address-parser example snippets
return [
// Reserved for future customization: e.g. 'extra_street_suffixes' => [],
// 'extra_unit_indicators' => [],
];
use Awaisjameel\LaravelAddressParser\LaravelAddressParser;
$parsed = LaravelAddressParser::parseAddressString('500 Elm Avenue Apt 4B Metropolis NY 10001');
/* Result:
[
'address1' => '500 Elm Avenue',
'address2' => 'APT 4B',
'city' => 'Metropolis',
'state' => 'NY',
'zip' => '10001',
'county' => null,
]
*/
$parsed = LaravelAddressParser::parseAddressString('77 Broadway St #12 Gotham NJ 07001');
// address2 is '#12'
$parsed = LaravelAddressParser::parseAddressString('1600 Pennsylvania Avenue NW, Washington, DC 20500-0003');
$parsed = LaravelAddressParser::parseAddressStringWithCounty('123 Main St, Springfield, Greene, MO 65804');
// county => 'Greene'
$parsed = LaravelAddressParser::parseAddressStringWithCounty('1600 Pennsylvania Avenue NW, Washington, DC 20500');
// county => null
$formatted = LaravelAddressParser::formatAddress([
'address1' => '123 Main St',
'address2' => 'APT 4B',
'city' => 'Springfield',
'state' => 'IL',
'zip' => '62704',
]);
// "123 Main St APT 4B, Springfield, IL 62704"