# Posted By

quixrick on 12/18/12

# Statistics

Viewed 597 times
Favorited by 0 user(s)

# Fake Credit Card Checker

/ Published in: PHP
`// SET THE CARD NUMBER TO BE TESTED\$card_number = '';   // TEST THE CARD NUMBERif (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;	}   }`