Created
February 12, 2013 15:03
-
-
Save muhittin/4770453 to your computer and use it in GitHub Desktop.
MasterCard: Must have a prefix of 51 to 55, and must be 16 digits in length.
Visa: Must have a prefix of 4, and must be either 13 or 16 digits in length.
American Express: Must have a prefix of 34 or 37, and must be 15 digits in length.
Diners Club: Must have a prefix of 300 to 305, 36, or 38, and must be 14 digits in length.
Discover: Must have…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function credit_card_type($ccNum) | |
{ | |
if (ereg("^5[1-5][0-9]{14}$", $ccNum)) | |
return "Mastercard"; | |
if (ereg("^4[0-9]{12}([0-9]{3})?$", $ccNum)) | |
return "Visa"; | |
if (ereg("^3[47][0-9]{13}$", $ccNum)) | |
return "American Express"; | |
if (ereg("^3(0[0-5]|[68][0-9])[0-9]{11}$", $ccNum)) | |
return "Diners Club"; | |
if (ereg("^6011[0-9]{12}$", $ccNum)) | |
return "Discover"; | |
if (ereg("^(3[0-9]{4}|2131|1800)[0-9]{11}$", $ccNum)) | |
return "JCB"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment