Created
September 23, 2014 13:05
-
-
Save mlask/c174e6bf3e6b559e447d to your computer and use it in GitHub Desktop.
Weryfikacja numeru PWZ
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_pwz_number ($number) | |
{ | |
if (strlen($number) != 7 || preg_match('/^0+$/', $number)) return false; | |
$c = (int)$number[0]; | |
$n = substr($number, 1); | |
$s = 0; | |
for ($i = 1; $i <= 6; $i ++) $s += (int)$n[$i - 1] * $i; | |
return ($s % 11) == $c ? true : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment