note 11400 modified in ref.math by aidan

From: Date: Sat, 26 Jun 2004 03:12:29 +0000
Subject: note 11400 modified in ref.math by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71708@lists.php.net to get a copy of this message
for those looking for a credit card verification function i wrote a simple LUHN Formula algorithm: <?php $valid = 1; $numOfDigits = 0 - strlen($ccNumber); $i = -1; while ($i>=$numOfDigits){ if (($i % 2) == 0){ $double = 2*(substr($ccNumber, $i, 1)); $total += substr($double,0,1); if (strlen($double > 1)){ $total += substr($double,1,1); } } else { $total += substr($ccNumber, $i, 1); } $i--; } if (($total % 10) != 0){ $valid = 0; } ?> --was-- for those looking for a credit card verification function i wrote a simple LUHN Formula algorithm: $valid = 1; $numOfDigits = 0 - strlen($ccNumber); $i = -1; while ($i>=$numOfDigits){ if (($i % 2) == 0){ $double = 2*(substr($ccNumber, $i, 1)); $total += substr($double,0,1); if (strlen($double > 1)){ $total += substr($double,1,1); } } else { $total += substr($ccNumber, $i, 1); } $i--; } if (($total % 10) != 0){ $valid = 0; } http://php.net/manual/en/ref.math.php

« previous php.notes (#71708) next »