本文主要介绍了php从身份证获取性别和出生年月的方法。具有很好的参考价值
话不多说,请看代码:
//通过身份证号查询出性别与生日
$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为女//通过身份证号查询出性别与生日
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';以上就是本文的全部内容,希望对大家的学习有所帮助。
相关推荐:
立即学习“PHP免费学习笔记(深入)”;
以上就是php从身份证获取性别和出生年月的方法的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号