Home > php教程 > PHP源码 > body text

中国气象中国地区县市编码数据

PHP中文网
Release: 2016-05-25 17:05:57
Original
1517 people have browsed it

前段时间osc上有人要中国气象网的地区编码数据,这里提供一下。
中国气象网对地区有自己的一套编码,并非用邮编编码,这里是中国气象的中国地区编码数据,细到县区。
比如:101210101,这个是杭州市城区的地区码,下面讲解一下这个编码规则。
前三位101是国家编码,101就是中国了,21是省编码,21=浙江省,再往下两位01就是杭州的编码,最后两位01是杭州下属县区的编码。
101 21 01 01
国    省  市  县
代码区是php解析数据的代码
具体的地区编码在这里下载:http://www.hao535.com/wp-content/uploads/2013/04/area.rar

<?php
$area = file_get_contents("area.php");
$area = unserialize($area);
//print_r($area);
$province = array();
foreach($area as $k => $v){
$province[$k] = $v[&#39;level0&#39;];
}
//print_r($province);

// 找江苏省南京市江宁区代号
$pid = array_search(&#39;江苏&#39;,$province);
if($pid !== false){
echo $pid;
$citys = $area[$pid][&#39;level1&#39;];// 江苏所有地级市
$cityid = array_search(&#39;南京&#39;,$citys);
if($cityid !== false){
echo &#39;,&#39;.$cityid;
// 县区
$countys = $area[$pid][&#39;level2&#39;][$cityid];
$countyid = array_search(&#39;江宁&#39;,$countys);
if($countyid !== false){
echo &#39;,&#39;.$countyid;
echo &#39;中国气象id:&#39;.$area[$pid][&#39;level3&#39;][$countyid];
}else{
echo &#39;no countyid&#39;;
}
}else
echo &#39;no cid&#39;;
}else
echo &#39;no pid&#39;;
Copy after login

                   


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!