<?php# PHP IBAN - http://code.google.com/p/php-iban - LGPLv3# Global flag by request$__disable_iiban_gmp_extension=false;# Verify an IBAN number. Returns true or false.# NOTE: Input can be printed 'IIBAN xx xx xx...' or 'IBAN xx xx xx...' or machine 'xxxxx' format.function verify_iban($iban) {# First convert to machine format.$iban = iban_to_machine_format($iban);# Get country of IBAN$country = iban_get_country_part($iban);# Test length of IBANif(strlen($iban)!=iban_country_get_iban_length($country)) { return false; }# Get checksum of IBAN$checksum = iban_get_checksum_part($iban);# Get country-specific IBAN format regex$regex = '/'.iban_country_get_iban_format_regex($country).'/';# Check regexif(preg_match($regex,$iban)) {# Regex passed, check checksumif(!iban_verify_checksum($iban)) {return false;}}else {return false;}# Otherwise it 'could' existreturn true;}# Convert an IBAN to machine format. To do this, we# remove IBAN from the start, if present, and remove# non basic roman letter / digit charactersfunction iban_to_machine_format($iban) {# Uppercase and trim spaces from left$iban = ltrim(strtoupper($iban));# Remove IIBAN or IBAN from start of string, if present$iban = preg_replace('/^I?IBAN/','',$iban);# Remove all non basic roman letter / digit characters$iban = preg_replace('/[^a-zA-Z0-9]/','',$iban);