Created
September 23, 2014 13:03
-
-
Save mlask/de138c238735fa48accc to your computer and use it in GitHub Desktop.
Weryfikacja numeru REGON
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_regon_number ($number) | |
{ | |
$w = array(7 => array(2, 3, 4, 5, 6, 7), 9 => array(8, 9, 2, 3, 4, 5, 6, 7), 14 => array(2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8)); | |
if (!isset($w[$l = strlen($number = preg_replace('/[^0-9]/', '', $number))])) return false; | |
for ($s = $i = 0; $i < $l - 1; $i ++) | |
$s += $number[$i] * $w[$l][$i]; | |
return $number[$l - 1] == (($s % 11) % 10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment