Php determines the region (province) address based on the ID card number

Source: Internet
Author: User

Php determines the region (province) address based on the ID card number

Php determines the region (mainly the province or municipality) based on the ID card number and the detailed address of the district/county. The Code is as follows:

<? Php/*** calculate the province and detailed district/county address based on the id card */class addr {/** obtain the province **/public static function getProvince ($ id) {// intercept the first two digits $ index = substr ($ id,); $ area = array (11 => "Beijing", 12 => "Tianjin ", 13 => "Hebei ",......); return $ area [$ index];}/** get address **/public static function getAddress ($ id) {$ index = substr ($ id ); $ areaArray ['000000'] = 'datong city, Shanxi Province '; $ areaArray ['000000'] = 'datong City mining area, Shanxi Province '; $ areaArray ['000000'] = 'Southern suburb of Datong City, Shanxi Province ';...... return $ areaArray [$ index] ;}}

For the complete code, click Download below:

Addr. class. php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.