What's wront in this iban validation code?
Posted
by Jackoder
on Stack Overflow
See other posts from Stack Overflow
or by Jackoder
Published on 2010-04-06T00:50:10Z
Indexed on
2010/04/06
0:53 UTC
Read the original article
Hit count: 408
Hello coders,
I'm working on a php iban validator but i have a problem
I wrote like this:
function IbanValidator($value) {
$iban = false;
$value= strtoupper(trim($value));
# Change US text into your country code
if(preg_match('/^US\d{7}0[A-Z0-9]{16}$/', $value)) {
$number= substr($value,4,22).'2927'.substr($value,2,2);
$number= str_replace(
array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'),
array(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35),
$number
);
$iban = (1 == bcmod($number,97)) ? true;
}
return $iban; }
Thanks.
© Stack Overflow or respective owner