Revision: 61494
at December 18, 2012 08:55 by quixrick

Initial Code
```// SET THE CARD NUMBER TO BE TESTED
\$card_number = '';

// TEST THE CARD NUMBER
if (is_card_fake(\$card_number)) {
print "It's Possible This Card Is Valid";
}
else {
print "Card Cannot Possibly Be Valid.";
}

function is_card_fake(\$card_number) {

\$number_sum = 0;

// SPLIT THE CARD NUMBER INTO 16 INDIVIDUAL DIGITS
\$digits = preg_split('//', \$card_number, -1, PREG_SPLIT_NO_EMPTY);

// LOOP THROUGH THE DIGITS
for (\$i = 0; \$i < strlen(\$card_number); \$i++) {

// CHECK TO SEE IF WE SHOULD DOUBLE THE NUMBER OR JUST ADD IT
if (\$i % 2 == 0) {

// DOUBLE THE DIGITS
\$double_number = \$digits[\$i] * 2;

// IF THE DOUBLED NUMBER IS 10 OR MORE, SPLIT IT APART AND ADD EACH PIECE TO THE SUM
if (\$double_number > 9) {
\$doubled_digits = preg_split('//', \$double_number, -1, PREG_SPLIT_NO_EMPTY);
\$number_sum += \$doubled_digits[0] + \$doubled_digits[1];
}
// OTHERWISE, JUST ADD THE DOUBLED NUMBER TO THE SUM
else {
\$number_sum += \$double_number;
}

}
// WE DO NOT HAVE TO DOUBLE THESE DIGITS; JUST ADD THEM TO THE SUM
else {
\$number_sum += \$digits[\$i];
}

}

// CHECK TO SEE IF THE SUM OF THE DIGITS CAN BE DIVIDED BY 10
if (\$number_sum % 10 == 0) {
return true;
}
else {
return false;
}

}```

Initial URL

Initial Description
`This function checks to see if a credit card number cannot possibly be valid.  Note: It does NOT check if a card is valid.  A card number can pass this check and still be invalid, but this script will identify card numbers that cannot possibly be valid.`

Initial Title
`Fake Credit Card Checker`

Initial Tags

Initial Language
`PHP`