PHP code example of vvk / id-card

1. Go to this page and download the library: Download vvk/id-card library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vvk / id-card example snippets



use Vvk\IdCard\IdCard;

$idCard = '110101192009309116';
$location = IdCard::parse($idCard);//支持15位、18位身份证号
print_r($location);
/*
结果:
Array
(
    [province] => 北京市
    [city] => 北京市
    [district] => 东城区
    [area] => 北京市 北京市 东城区
    [date] => 1920-09-30
    [sex] => 男
    [constellation] => 天秤座
)
*/


use Vvk\IdCard\IdCard;

//通过 IdCard::getLocation() 获取到的对应的区、县code
//广东东莞市、广东中山市、海南儋州三个城市下面没有区、县,只在在对应的城市后面补助 00 组成6位字符串即可
$location = '110101';

// 日期格式为 YYYmmdd
$date = '20201003';
$result = IdCard::generate($location, $date, 1);
echo $result.PHP_EOL;
/**
结果:
110101202010035331
*/


use Vvk\IdCard\IdCard;

$idCard = '320506720102256';
$result = IdCard::getLongIdCard($idCard);
echo $result.PHP_EOL;
/*
结果:
320506197201022567
*/


use Vvk\IdCard\UpdateLocation;

UpdateLocation::run();