$results = array(); foreach ($list as $iban) { if ($iban != '') { # let's check it print $iban . " ... "; if (!verify_iban($iban)) { print "FAILED"; ########## try to provide better output ############# $iban = iban_to_machine_format($iban); $country = iban_get_country_part($iban); $observed_length = strlen($iban); $expected_length = iban_country_get_iban_length($country); if ($observed_length != $expected_length) { print " (length {$observed_length} does not match expected length {$expected_length} for country {$country})"; } $checksum = iban_get_checksum_part($iban); if (!iban_verify_checksum($iban)) { print " (checksum {$checksum} invalid)"; } $regex = '/' . iban_country_get_iban_format_regex($country) . '/'; if (!preg_match($regex, $iban)) { print " (does not match regex {$regex} for country {$country})"; } #################################################### $errors++; $suggestions = iban_mistranscription_suggestions($iban); if (is_array($suggestions)) { if (count($suggestions) == 1) { print " (you meant '" . $suggestions[0] . "', right?)"; } elseif (count($suggestions) > 1) { print " (perhaps ";
# start section print "[{$countrycode}: " . iban_country_get_country_name($countrycode) . "]\n"; # output remaining country properties print "Is a SEPA member? "; if (iban_country_is_sepa($countrycode)) { print "Yes"; } else { print "No"; } print ".\n"; # get example iban $iban = $country['iban_example']; # output example iban properties one by one print "Example IBAN: " . iban_to_human_format($iban) . "\n"; print " - country " . iban_get_country_part($iban) . "\n"; print " - checksum " . iban_get_checksum_part($iban) . "\n"; print " - bban " . iban_get_bban_part($iban) . "\n"; print " - bank " . iban_get_bank_part($iban) . "\n"; print " - branch " . iban_get_branch_part($iban) . "\n"; print " - account " . iban_get_account_part($iban) . "\n"; # output all properties #$parts = iban_get_parts($iban); #print_r($parts); # verify print "\nChecking validity... "; if (verify_iban($iban)) { print "IBAN {$iban} is valid.\n"; } else { print "ERROR: IBAN {$iban} is invalid.\n"; $errors++; }
public function Checksum($iban = '') { return iban_get_checksum_part($this->iban); }
function iban_get_parts($iban) { return array('country' => iban_get_country_part($iban), 'checksum' => iban_get_checksum_part($iban), 'bban' => iban_get_bban_part($iban), 'bank' => iban_get_bank_part($iban), 'country' => iban_get_country_part($iban), 'branch' => iban_get_branch_part($iban), 'account' => iban_get_account_part($iban)); }
function _iban_nationalchecksum_set($iban, $nationalchecksum) { $country = iban_get_country_part($iban); $start = iban_country_get_nationalchecksum_start_offset($country); if ($start == '') { return ''; } $stop = iban_country_get_nationalchecksum_stop_offset($country); if ($stop == '') { return ''; } # determine the BBAN $bban = iban_get_bban_part($iban); # alter the BBAN $firstbit = substr($bban, 0, $start); # 'string before the checksum' $lastbit = substr($bban, $stop + 1); # 'string after the checksum' $fixed_bban = $firstbit . $nationalchecksum . $lastbit; # reconstruct the fixed IBAN $fixed_iban = $country . iban_get_checksum_part($iban) . $fixed_bban; return $fixed_iban; }