Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mlask
Created September 23, 2014 13:03
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/de138c238735fa48accc to your computer and use it in GitHub Desktop.
Save mlask/de138c238735fa48accc to your computer and use it in GitHub Desktop.
Weryfikacja numeru REGON
<?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