Table of Contents
php function to extract the birthday date from the ID card number and verify whether it is an adult, ID card number for adults
Home Backend Development PHP Tutorial PHP function to extract the birthday date from the ID card number and verify whether it is an adult, ID card number is an adult_PHP tutorial

PHP function to extract the birthday date from the ID card number and verify whether it is an adult, ID card number is an adult_PHP tutorial

Jul 12, 2016 am 09:08 AM
identification number Verification function

php function to extract the birthday date from the ID card number and verify whether it is an adult, ID card number for adults

php extract the birthday date from the ID card number and determine whether it is an adult A function of adulthood. It can determine 15-digit and 18-digit ID cards at the same time. After personal testing, it is very easy to use. The shared function code is as follows:

<&#63;php
//用php从身份证中提取生日,包括位和位身份证
function getIDCardInfo($IDCard){
  $result['error']=;//:未知错误,:身份证格式错误,:无错误
  $result['flag']='';//标示成年,标示未成年
  $result['tdate']='';//生日,格式如:--
  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']=;//:未知错误,:身份证格式错误,:无错误
  $result['isAdult']=$flag;//标示成年,标示未成年
  $result['birthday']=$tdate;//生日日期
  return $result;
}
Copy after login

Usage is as follows:

Copy code The code is as follows:
getIDCardInfo('ID card number');

The above code is the php function that the editor shared with you to extract the birthday date from the ID card number and verify whether it is an adult. I hope it will be useful to everyone.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1058165.htmlTechArticlephp function to extract the birthday date in the ID number and verify whether it is an adult, ID number adult php Extract the birthday date from the ID number and determine whether you are an adult...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Python regular expressions to extract ID number How to use Python regular expressions to extract ID number Jun 22, 2023 am 10:35 AM

In the process of data processing, it is often necessary to extract information in a specific format from text. As a relatively common piece of personal information, ID number is often used in data processing. You can use Python regular expressions to easily extract the ID number and perform certain verification on it. The ID card number is composed of 18 digits, including the region, date of birth, check code and other information in the ID card number. In Python, we can use the regular expression function of the re module to extract the ID number. head

PHP regular expression to verify whether the input string is in the format of ID number or passport number PHP regular expression to verify whether the input string is in the format of ID number or passport number Jun 24, 2023 pm 12:11 PM

ID number and passport number are common document numbers in people's lives. When implementing functions involving these document numbers, it is often necessary to perform format verification on the entered numbers to ensure their correctness. In PHP, regular expressions can be used to achieve this function. This article will introduce how to use PHP regular expressions to verify whether the input string is in the format of an ID number or passport number. 1. ID card number verification The ID card number is composed of 18 digits and the last digit may be a letter (check code). Its format is as follows: the first 6

PHP regular expression to verify birthday information of ID number PHP regular expression to verify birthday information of ID number Jun 24, 2023 pm 02:22 PM

The ID number is an identity proof tool that we often use in our daily lives, and the birthday information contained in it is also very important. When using PHP to verify ID numbers, we often need to determine whether the birthday information is correct. This article will introduce how to use PHP regular expressions to verify the birthday information of the ID number. 1. The basic format of the ID number. The ID number is a string composed of 18 digits and letters. The last digit may be a number or a letter, and may be uppercase or lowercase. The first 17 digits are the owner of the ID card

How to use PHP regular expressions to verify whether the input string is the correct ID number, passport number or Hong Kong and Macao pass format How to use PHP regular expressions to verify whether the input string is the correct ID number, passport number or Hong Kong and Macao pass format Jun 24, 2023 am 10:36 AM

ID cards, passports and Hong Kong and Macao pass numbers are all important personal identity certificates. In order to ensure the security of personal information, we need to verify in the system whether the ID number entered by the user complies with the standard format. PHP regular expressions are a very powerful tool that can easily achieve this purpose. This article will introduce how to use PHP regular expressions to verify the ID number, passport number and Hong Kong and Macao pass number entered by the user. 1. ID card number format verification The ID card number is an 18-digit number, and the last digit may be a number or the letter X. identity

How to use the input box carriage return event and verification function in the Vue document How to use the input box carriage return event and verification function in the Vue document Jun 20, 2023 am 09:13 AM

Vue is a popular JavaScript front-end framework with a responsive data binding and component system at its core. In Vue applications, the input box is one of the most commonly used UI elements. When the user enters text, we hope to listen for the carriage return event and validate the input before submitting. This article will introduce the input box enter event and verification function usage in the Vue document. 1. The carriage return event of the input box in Vue. Monitoring the carriage return event of the input box in Vue is very simple.

PHP regular expression method to verify the validity and gender of ID number PHP regular expression method to verify the validity and gender of ID number Jun 24, 2023 am 09:36 AM

The ID number is an important symbol for the identification of residents in our country, and it can be used for identity verification on many occasions. In the application, in order to ensure the validity and accuracy of the ID number, it needs to be verified by regular expressions. This article will introduce how to use PHP regular expressions to verify the validity and gender of the ID number. 1. The composition and rules of the ID card number The ID card number consists of 18 digits or 17 digits plus a 1-digit check code. Among them, the first 17 digits represent the ID card holder’s information, and the last 1 digit represents the verification code, which is used to verify the ID card.

PHP regular expression to verify the check code of ID card number PHP regular expression to verify the check code of ID card number Jun 24, 2023 am 10:42 AM

When developing using PHP, it often involves verifying the ID number entered by the user to ensure the accuracy and completeness of the data. The verification code in the ID number is a very important part, it can help us determine whether the ID number is legal. Therefore, when using PHP to verify the ID number, we need to understand how to use regular expressions to verify the check code in the ID number. 1. What is the verification code of the ID number? The ID card number is an important document that every Chinese citizen must possess. It consists of 18

How to use regular expressions in Go language to determine whether a string is a legal ID number How to use regular expressions in Go language to determine whether a string is a legal ID number Jul 13, 2023 pm 07:55 PM

How to use regular expressions in Go language to determine whether a string is a legal ID number. The ID number is a unique identifier for each Chinese citizen and is also an important basis for identifying individuals in all aspects of society. In data processing, it is often necessary to determine whether a string is a legal ID number. This article will introduce how to use regular expressions in Go language to determine whether a string is a legal ID number. In Go language, using regular expressions requires introducing the regexp package. The following is a regular expression to determine the ID number

See all articles