Routing Number Check Sum Algorithm in PHP (371 371 371). Check it out.
<?php
function routingNumberCheckSum($routingNumber)
{
$routingArray = array();
$total = 0;
$i = 0;
for($i = 0; $i < strlen($routingNumber); $i++)
{
if (!isset($routingArray[$i])) {$routingArray[$i] = 0;}
$routingArray[$i] = intval(substr($routingNumber,$i,1));
if ( $i % 3 == 0 )
{
$routingArray[$i] = $routingArray[$i] * 3;
}
elseif ($i % 3 == 1)
{
$routingArray[$i] = $routingArray[$i] * 7;
}
$total = $total + $routingArray[$i];
}
if ($total % 10 === 0)
{
return "true";
}
else
{
return "false";
}
}
?>
<?php
function routingNumberCheckSum($routingNumber)
{
$routingArray = array();
$total = 0;
$i = 0;
for($i = 0; $i < strlen($routingNumber); $i++)
{
if (!isset($routingArray[$i])) {$routingArray[$i] = 0;}
$routingArray[$i] = intval(substr($routingNumber,$i,1));
if ( $i % 3 == 0 )
{
$routingArray[$i] = $routingArray[$i] * 3;
}
elseif ($i % 3 == 1)
{
$routingArray[$i] = $routingArray[$i] * 7;
}
$total = $total + $routingArray[$i];
}
if ($total % 10 === 0)
{
return "true";
}
else
{
return "false";
}
}
?>
No comments:
Post a Comment