php 주민등록번호 체크 함수
로빈아빠
본문
function is_jumin($jumin)
{
if(!is_numeric($jumin))
return false;
if(strlen($jumin) != 13)
return false;
$sum_1 = $sum_2 = $at = 0;
$k = 2;
for($i = 0; $i < 12; $i++, $k++)
{
if($k > 9)
$k = 2;
$sum_1 += intval(substr($jumin, $i, 1)) * $k;
}
$sum_2 = $sum_1 % 11;
if($sum_2 == 0)
$at = 10;
else
{
if($sum_2 == 1)
$at = 11;
else
$at = $sum_2;
}
$att = 11 - $at;
if(intval(substr($jumin, 12, 1)) != $att || substr($jumin, 2, 2) < '01' || substr($jumin, 2, 2) > '12' || substr($jumin, 4, 2) < '01' || substr($jumin, 4, 2) > '31' || intval(substr($jumin, 6, 1)) > 4)
return false;
else
return true;
}
관련링크
댓글목록
등록된 댓글이 없습니다.