- <?php
- function roundup ($number, $increments) {
- $increments = 1 / $increments;
- }
- $num = "49927398717";
- $double = false;
- $ret = "";
- $ret .= ($double ? $num[$i] * 2 : $num[$i]);
- $double = !$double;
- }
- $sum = 0;
- $sum += $ret[$i];
- }
- echo "\$ret = $ret\n";
- echo "\$sum = $sum\n";
- if ($sum % 10) {
- $check_digit = roundup($sum, 10) - $sum;
- echo "Invalid - (Valid with check digit $check_digit)\n";
- } else {
- echo "Valid\n";
- }
- ?>
Luhn algorithm
Posted by Admin on Fri 11th Feb 2011 02:06
raw | new post
view followups (newest first): Luhn algorithm by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.