PHP extracts the birthday date in the ID number and a function to determine whether it is adult. Can be determined at the same time 15-bit and 18-bit ID card, by my own test, very useful, sharing function code is as follows:
<?php///use PHP to extract birthdays from ID cards, including bit and bit ID function getidcardinfo ($IDCard) {$result [' Error ']=;//: Unknown error: ID card 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: ID card format error: no error $result [' Isadult ']= $flag; Mark Adult, Mark underage $result [' Birthday '
]= $tdate;//Birthday date return $result; }
Usage is as follows:
Copy Code code as follows:
Getidcardinfo (' ID number ');
The above code is a small series to share with you the PHP ID number of the date of the birthday and verify whether the function of adults, I hope to be useful.