PHP Extract the birthday date in the ID number and verify whether it is an adult function, ID number adult _php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.