PHP2008. 11. 6. 10:56
<!--StartFragment-->$bbs_contents = '본문내용에 주민번호와 그렇지않은 번호를 넣어보세요....';


$pattern = '/^d{6}-d{7}$/';
$pattern = '/[0-9]{6}(-|*|_|=|[[:space:]])*[1|2|3|4][0-9]{6}/';
preg_match_all($pattern, $bbs_contents, $matches, PREG_SET_ORDER);

$i=0;
foreach ($matches as $val) {
    preg_match("/(d{6}).*(d{7})/",$val[0],$res);

    $chk_jumin =$res[1].$res[2];
    echo $chk_jumin.' => ';
    if(RegiNum($chk_jumin)) {
        echo ' true, ';
        $bbs_contents = str_replace($val[0],'<font color="#ff8800">'.$val[0].'</font>',$bbs_contents);
    } else {
        $bbs_contents = str_replace($val[0],'<font color="blue">'.$val[0].'</font>',$bbs_contents);
        echo ' false, ';
    }
    $i++;
}


function RegiNum($reginum) {
$weight = '234567892345'; // 자리수 weight 지정
$len = strlen($reginum);
$sum = 0;

if ($len <> 13) { return false; }

for ($i = 0; $i < 12; $i++) {
$sum = $sum + (substr($reginum,$i,1) * substr($weight,$i,1));
}

$rst = $sum%11;
$result = 11 - $rst;

if ($result == 10) {$result = 0;}
else if ($result == 11) {$result = 1;}

$jumin = substr($reginum,12,1);

if ($result <> $jumin) {return false;}
return true;
}

Posted by 아마데우스