Created
September 23, 2014 13:00
-
-
Save mlask/a374a4337d092b08d653 to your computer and use it in GitHub Desktop.
Weryfikacja numeru PESEL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function check_pesel_number ($number) | |
{ | |
$w = array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3); | |
if (($l = strlen($number = preg_replace('/[^0-9]/', '', $number))) !== count($w) + 1) return false; | |
for ($s = $i = 0; $i < $l - 1; $i ++) | |
$s += $number[$i] * $w[$i]; | |
return $number[$l - 1] == ((10 - ($s % 10)) % 10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testowy Gist... ;)