1. Go to this page and download the library: Download hejunjie/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/ */
public static function parse(
string $string, // Raw address string to parse
bool $user = true, // Whether to extract user info (name, phone, ID, postcode)
string $unknownValue = '未知', // Fallback value when a region cannot be matched
array $level1Data = [], // Custom province-level data; uses built-in data if empty
array $level2Data = [], // Custom city-level data
array $level3Data = [] // Custom district/county-level data
): array
$addresses = [
'张三 13512345678 北京市朝阳区望京SOHO 邮编100000',
'李四 13800138000 上海市浦东新区陆家嘴金融中心88号',
];
foreach ($addresses as $raw) {
$result = AddressParser::parse($raw);
// Process each result...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.