PHP PESEL validation
function validPESEL($str)
{
if (!preg_match('/^[0-9]{11}$/',$str))
{
return false;
}
$arrSteps = array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3);
$sum = 0;
for ($i = 0; $i < 10; $i++)
{
$sum += $arrSteps[$i] * $str[$i];
}
$int = 10 - $sum % 10;
$controlNr = ($int == 10)?0:$int;
if ($controlNr == $str[10])
{
return true;
}
return false;
}