当前位置: 移动技术网 > IT编程>开发语言>PHP > php从身份证获取性别和出生年月

php从身份证获取性别和出生年月

2017年12月12日  | 移动技术网IT编程  | 我要评论

话不多说,请看代码:

//通过身份证号查询出性别与生日
 $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';

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持移动技术网!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网