Permalink
Browse files

Added ABA validation funtion.

  • Loading branch information...
ethem
ethem committed Aug 30, 2006
1 parent b4f3a93 commit e2863967c69b418b13103533413d20f63fe422b4
Showing with 26 additions and 0 deletions.
  1. +26 −0 enrol/authorize/abaval.php
View
@@ -0,0 +1,26 @@
+<?php // $Id$
+
+/**
+ * Validates the supplied ABA number
+ * using a simple mod 10 check digit routine.
+ *
+ * @param string $aba Bank ID
+ * @return bool true ABA is valid, false otherwise
+ */
+function ABAVal($aba)
+{
+ if (ereg("^[0-9]{9}$", $aba)) {
+ $n = 0;
+ for($i = 0; $i < 9; $i += 3) {
+ $n += (substr($aba, $i, 1) * 3) +
+ (substr($aba, $i + 1, 1) * 7) +
+ (substr($aba, $i + 2, 1));
+ }
+ if ($n != 0 and $n % 10 == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+?>

0 comments on commit e286396

Please sign in to comment.