fork(4) download
  1. <?php
  2. $iban = "3214282912345698765432161182";
  3.  
  4. $first = substr($iban, 0, 9);
  5. $array = str_split(substr($iban, 9),7);
  6.  
  7. $result = $first % 97;
  8. foreach ($array as &$value) {
  9. $result = intval( strval($result) . $value) % 97;
  10. }
  11.  
  12. if ($result == 1) {
  13. echo "IBAN:$iban is valid";
  14. } else {
  15. echo "IBAN:$iban invalid remainder:$result";
  16. }
  17.  
  18. ?>
  19.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
IBAN:3214282912345698765432161182 is valid