使用前请先导入数据,如需更新数据,请前往 https://github.com/xiangyuecn/AreaCity-JsSpider-StatsGov 下载最新的地域数据
areacity:get($id) 获取id对应的地区信息
如:
C('areacity:get',330109);
返回:
Array
(
[id] => 330109
[pid] => 3301
[deep] => 2
[name] => 萧山
[pinyin_prefix] => x
[pinyin] => xiao shan
[ext_id] => 330109000000
[ext_name] => 萧山区
)
areacity:getParents($id) 获取id所有的父地区信息(包含自身)
如:
C('areacity:getParents',330109);
返回:
Array
(
[0] => Array
(
[id] => 33
[pid] => 0
[deep] => 0
[name] => 浙江
[pinyin_prefix] => z
[pinyin] => zhe jiang
[ext_id] => 330000000000
[ext_name] => 浙江省
)
[1] => Array
(
[id] => 3301
[pid] => 33
[deep] => 1
[name] => 杭州
[pinyin_prefix] => h
[pinyin] => hang zhou
[ext_id] => 330100000000
[ext_name] => 杭州市
)
[2] => Array
(
[id] => 330109
[pid] => 3301
[deep] => 2
[name] => 萧山
[pinyin_prefix] => x
[pinyin] => xiao shan
[ext_id] => 330109000000
[ext_name] => 萧山区
)
)
areacity:getParentsName($id) 获取id对应的完整地区名称
如:
C('areacity:getParentsName',330109);
返回:
浙江省杭州市萧山区