根据身份证获取所在省份对照表

根据身份证获取所在省份对照表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$province = [
11 => '北京',
12 => '天津',
13 => '河北',
14 => '山西',
15 => '内蒙古',
21 => '辽宁',
22 => '吉林',
23 => '黑龙江',
31 => '上海',
32 => '江苏',
33 => '浙江',
34 => '安徽',
35 => '福建',
36 => '江西',
37 => '山东',
41 => '河南',
42 => '湖北',
43 => '湖南',
44 => '广东',
45 => '广西',
46 => '海南',
50 => '重庆',
51 => '四川',
52 => '贵州',
53 => '云南',
54 => '西藏',
61 => '陕西',
62 => '甘肃',
63 => '青海',
64 => '宁夏',
65 => '新疆',
71 => '台湾',
81 => '香港',
82 => '澳门'

];

如果你在laravel框架里,不妨在helper文件里写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//从身份证里取所在地区
if (!function_exists('get_province_by_card')) {
function get_province_by_card($card = '')
{
if (!empty($card)) {
$province = [
11 => '北京',
12 => '天津',
13 => '河北',
14 => '山西',
15 => '内蒙古',
21 => '辽宁',
22 => '吉林',
23 => '黑龙江',
31 => '上海',
32 => '江苏',
33 => '浙江',
34 => '安徽',
35 => '福建',
36 => '江西',
37 => '山东',
41 => '河南',
42 => '湖北',
43 => '湖南',
44 => '广东',
45 => '广西',
46 => '海南',
50 => '重庆',
51 => '四川',
52 => '贵州',
53 => '云南',
54 => '西藏',
61 => '陕西',
62 => '甘肃',
63 => '青海',
64 => '宁夏',
65 => '新疆',
71 => '台湾',
81 => '香港',
82 => '澳门'

];
return array_get($province, substr($card, 0, 2), '');
}
return $card;
}
}

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×