Home Article 地址分割

地址分割

Source:地址分割 Release time:2019-07-22 Author:Mr.赵 Reading volume:31
$address="江西省上饶市信州区星河国际3-715";
preg_match('/(.*?(省|自治区|北京市|天津市))/', $address, $matches);
if (count($matches) > 1) {
$province = $matches[count($matches) - 2];
$address = str_replace($province, '', $address);
}
preg_match('/(.*?(市|自治州|地区|区划|县))/', $address, $matches);
if (count($matches) > 1) {
$city = $matches[count($matches) - 2];
$address = str_replace($city, '', $address);
}
preg_match('/(.*?(区|县|镇|乡|街道))/', $address, $matches);
if (count($matches) > 1) {
$area = $matches[count($matches) - 2];
$address = str_replace($area, '', $address);
}
$a= [
'province' => isset($province) ? $province : '',
'city' => isset($city) ? $city : '',
'area' => isset($area) ? $area : '',
];
print_r($a);
  
I want to comment
Leave a message
http://boke.zhaozhiqi.top/index.php/
User login
You have not written any reviews yet!
You have commented!
Can only praise once!
You have a collection!