Skip to content

Instantly share code, notes, and snippets.

@mlask
Created September 23, 2014 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlask/a374a4337d092b08d653 to your computer and use it in GitHub Desktop.
Save mlask/a374a4337d092b08d653 to your computer and use it in GitHub Desktop.
Weryfikacja numeru PESEL
<?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);
}
@mlask
Copy link
Author

mlask commented Sep 23, 2014

Testowy Gist... ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment