This article uses php Technology to extract the birthday date in the ID card number to determine whether it is a function of a minor. The following code is a function used to extract the birthday date in the ID card number and determine whether the ID card number is an adult. You can determine the ID card of 15 and 18 digits at the same time. It is very useful after my own test. The function code is as follows:
<? Php // Use php to extract the birthday from the ID card, including the bit and bit ID card function getIDCardInfo ($ IDCard) {$ result ['error'] =; // unknown error ,: incorrect ID card format: no error $ result ['flag'] = ''; // indicates the adult, indicating the minor $ result ['tdate'] =''; // birthday, format: -- if (! Eregi ("^ [-] ([-a-zA-Z] {}| [-a-zA-Z] {}) $", $ IDCard )) {$ result ['error'] =; return $ result;} else {if (strlen ($ IDCard) =) {$ tyear = intval (substr ($ IDCard,); $ tmonth = intval (substr ($ IDCard ,,)); $ tday = intval (substr ($ IDCard,); if ($ tyear> date ("Y") | $ tyear <(date ("Y ")-)) {$ flag =;} elseif ($ tmonth <| $ tmonth>) {$ flag =;} elseif ($ tday <| $ tday>) {$ flag = ;} else {$ tdate = $ tyear. "-". $ tmonth. "-". $ tday. ":"; if (time ()-mktime (, $ tmonth, $ tday, $ tyear)> *****) {$ flag = ;} else {$ flag =;}} elseif (strlen ($ IDCard) ==) {$ tyear = intval ("". substr ($ IDCard,); $ tmonth = intval (substr ($ IDCard,); $ tday = intval (substr ($ IDCard ,,)); if ($ tyear> date ("Y") | $ tyear <(date ("Y")-) {$ flag = ;} elseif ($ tmonth <| $ tmonth>) {$ flag =;} elseif ($ tday <| $ tday>) {$ flag = ;} else {$ tdate = $ tyear. "-". $ tmonth. "-". $ tday. ":"; if (time ()-mktime (, $ tmonth, $ tday, $ tyear)> *****) {$ flag = ;} else {$ flag =;}}}$ result ['error'] =; // unknown error: Incorrect ID card format ,: no error $ result ['isadresult'] = $ flag; // indicates the adult, indicating the minor $ result ['birthday'] = $ tdate; // return $ result on the birthday date ;}
The usage is as follows:
The Code is as follows:
GetIDCardInfo ('Id card number ');
The above code is a php function used to extract the birthday date in the ID card number and verify whether it is an adult.