Return to Snippet

Revision: 22589
at January 16, 2010 15:20 by tomaszsobczak


Initial Code
function is_valid_nip($nip_number)
{
  $nip_digits  = array_filter(preg_split('//', $nip_number, -1, PREG_SPLIT_NO_EMPTY), 'is_numeric');
  $nip_length  = count($nip_digits);
  $nip_sum     = 0;
 
  if(10 != $nip_length)
  { return false; }
 
  foreach(array(6, 5, 7, 2, 3, 4, 5, 6, 7) as $weight)
  { $nip_sum += $weight * array_shift($nip_digits); }
    
  return (($nip_sum % 11) == array_shift($nip_digits));
}

Initial URL

                                

Initial Description

                                

Initial Title
PL VATID validator

Initial Tags

                                

Initial Language
PHP