Recent Posts
- (02/24) Calling an Element from a Helper TAGS:CakephpWeb ProgrammingUsageTutorialExample
- (10/14) Forcing A Single Join in CakePHP PaginationTAGS:CakephpCakephp 13DatabaseErrorsHabtmMysqlMssqlWeb ProgrammingUsage
- (08/11) Inserting NOW() into MySQL Using CakePHPTAGS:CakephpDatabaseMysqlMssqlWeb ProgrammingUsage
- (08/07) Best PaginateCount for CakePHP - with Group By SupportTAGS:CakephpBehaviorsWeb ProgrammingUsageDatabaseExampleMysqlHabtmHack
- (04/03) CakePHP Error Messages Not Showing on FormTAGS:CakephpCakephp 13Web ProgrammingErrorsUsage
- (02/06) Sorting Paginated Results Using a Related Model Field in CakePHPTAGS:CakephpWeb ProgrammingUsageExample
- (11/02) Changing CakePHP's Model useTable on the FlyTAGS:CakephpWeb ProgrammingMysqlDatabaseExampleTutorial
- (10/18) The Funniest Error Message Ever - Thank You EclipseTAGS:EclipseWeb ProgrammingErrorsHumorWindowsUsageSoftwarePhpCakephp
Subscribe to my feed
MainelyDesign.com Blog
PHP Function to Validate Bank Routing Numbers
Posted on 03/16/2010 at 04:10 pm by Kevin Wentworth
Viewed 3,610 times | 0 comments
I needed to validate that a Bank Routing Number was valid, much like the algorithms out there to check if a Credit Card number is valid. I did a little searching and didn't find a PHP function that would do the trick. I decided to write my own, based on this javascript function, and publish it for anyone who wants to use it:
Function to Validate Bank Routing Numbers:
- function checkRoutingNumber($routingNumber = 0) {
- return false;
- }
- $checkSum = 0;
- //loop through routingNumber character by character
- $checkSum += ($routingNumber[$i] * 3);
- $checkSum += ($routingNumber[$i+1] * 7);
- $checkSum += ($routingNumber[$i+2]);
- }
- if($checkSum != 0 and ($checkSum % 10) == 0) {
- return true;
- } else {
- return false;
- }
- }
Cheers,
-Kevin Wentworth
Tags for PHP Function to Validate Bank Routing Numbers
Php | Web Programming | Example
