public function checkIdCard($idcard_num='')
{
$idcard_len = strlen($idcard_num);
if($idcard_num == '' || !in_array($idcard_len,array(15,18)) ){
return false;
}
if($idcard_len === 15){
if(!preg_match("/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/", $idcard_num)){
return false;
}
}
if($idcard_len === 18){
if(!preg_match("/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(\d|x|X)$/", $idcard_num)){
return false;
}
}
return true;
}
网友评论