Posted By

jackoder on 04/05/10


Tagged

php validation iban


Versions (?)

Validate IBAN number with PHP


 / Published in: PHP
 

Here's a php code block that you can use in your projects like e-commerce, payment systems, etc.

Funny Games

  1. // functioan
  2. function IbanValidation($value) {
  3. $iban = false;
  4. $value= strtoupper(trim($value));
  5.  
  6. // Country US (can be changed into your country)
  7. if(preg_match('/^US\d{7}0[A-Z0-9]{16}$/', $value)) {
  8. $number = substr($value,4,22).'2927'.substr($value,2,2);
  9. $number = str_replace(
  10.  
  11. // Arrays in arrays
  12. 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'),
  13.  
  14. 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),
  15. $number
  16. );
  17.  
  18. $iban = (1 == bcmod($number,97)) ? true:false;
  19. }
  20. // return
  21. return $iban;
  22. }

Report this snippet  

You need to login to post a comment.