As designing a new platform we tried to integrate the IBAN numbers. We have to make sure that the IBAN is validated and the IBAN stored to the database is always correct. So what would be a proper way to validate the number?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Slight modification of @PeterFox answer including support for
bcmod()
whenbcmath
is not available,Sorry, I can not yet comment due to low Rep, so the new link to user3733632s answer:
https://github.com/globalcitizen/php-iban
(the project is no longer hosted at google code as of March 2015, and the project will get a new version after some cleanup.)
As the logic was explained in my other question I've tried to create a function myself. Based on the logic explained in the wikipedia article find a proper function below. Country specific validation.
Will it fit the
http://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN
top rated function does NOT work.
Just try a string with '%' in it...
I'm using this one :
The accepted answer is not the preferred way of validation, the specification dictates the following:
I've written a class that validates, formats and parses strings according to the spec, hope this helps save some the time to roll their own. Code found here:
https://gist.github.com/esserj/a54ffd11182417cf920d
Google Code hosts a project of an open source php-iban validator: https://code.google.com/p/php-iban/