How to get gender and date of birth from ID card in php

墨辰丷
Release: 2023-03-28 06:12:01
Original
2599 people have browsed it

This article mainly introduces the method of obtaining gender and birth date from ID card in php. It has a very good reference value

Without further ado, please look at the code:


//通过身份证号查询出性别与生日 $birth = strlen($idcard)==15 ? ('19' . substr($idcard, 6, 6)) : substr($idcard, 6, 8); $sex = substr($idcard, (strlen($idcard)==15 ? -2 : -1), 1) % 2 ? '1' : '0'; //1为男 2为女
Copy after login



//通过身份证号查询出性别与生日 if($data['cardtype'] == 'idcard'){ $data['birth'] = strlen($data['cardno'])==15 ? ('19' . substr($data['cardno'], 6, 6)) : substr($data['cardno'], 6, 8); $data['sex'] = substr($data['cardno'], (strlen($data['cardno'])==15 ? -2 : -1), 1) % 2 ? '1' : '0';
Copy after login



The above is the entire content of this article, I hope it will be helpful to everyone's study.


Related recommendations:

PHP implementationGetForm data and HTML embedded PHP script

Sample code for automaticallygettingform element values through JS code in Ajax

phpgetMethod to give the number of days difference between dates


The above is the detailed content of How to get gender and date of birth from ID card in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!