$char) { if ($index & 1) { $checksum += $char; } else { $checksum += $char * 3; } } $checksum = (10 - ($checksum % 10)) % 10; return $checksum; } }