PHP Extract the birthday date in the ID number and verify whether it is an adult function, ID number adult
PHP extracts the birthday date from the ID number and determines whether a function is adult. Can be determined at the same time 15-bit and 18-bit ID card, by my pro-test, very useful, share the function code as follows:
<?php//use PHP to extract birthdays from ID, including bit and bit ID card function Getidcardinfo ($IDCard) {$result [' Error ']=;//: Unknown error: ID format error: no error $result [ ' Flag ']= ';//mark Adult, Mark underage $result [' tdate ']= ';//birthday, format such as:-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: Identity card format error: no error $result [' Isadult ']= $flag;//marked adult, marked minor $result [' Birthday ']= $TDA te;//Birthday date return $result;}
Use the following:
Copy the Code code as follows:
Getidcardinfo (' ID card number ');
The above code is a small part of the PHP to share with you to extract the birthday date in the ID card number and verify whether it is an adult function, hope to be useful to everyone.
http://www.bkjia.com/PHPjc/1058165.html www.bkjia.com true http://www.bkjia.com/PHPjc/1058165.html techarticle php Extract the birthday date in the ID card number and verify whether it is an adult function, ID number adult PHP extract the birthday date in the ID number and determine whether the adult one ...