This article mainly describes
how PHP obtains gender and birth date methods from identity cards . Has a good reference value, following the PHP Chinese network small series together to see it
Please look at the code:
Gender and Birthday $birth = strlen ($idcard) ==15 by ID number? SUBSTR ($idcard, 6, 6): substr ($idcard, 6, 8); $sex = substr ($idcard, (strlen ($idcard) ==15?-2:-1), 1)% 2? ' 1 ': ' 0 '; 1 for male 2 for female
Search by ID number for gender and birthday if ($data [' cardtype '] = = ' Idcard ') {$data [' birth '] = strlen ($data [' Cardno ']) ==15? (' substr ' ($data [' Cardno '], 6, 6)): substr ($data [' Cardno '], 6, 8); $data [' sex '] = substr ($data [' Cardno '], (strlen ($data [' Cardno ']) ==15?-2:-1), 1)% 2? ' 1 ': ' 0 ';
For more information on how to get gender and date of birth from your ID from PHP, please follow the PHP Chinese web!