Php > Credit Cards
A set of functions to check the validity of a credit card number
A set of functions to check the validity of a credit card number ccValidate ($number, $type) returns 1 if the account number is valid, zero if not. The $type argument is optional. If included, it will perform additional checking to ensure the card is of the type specified. Valid types include: visa, mastercard, discover, and amex. =0; $i-=2){ $dbl[$j] = $dig[$i] * 2; $j++; } $dblsz = sizeof($dbl); $validate =0; for ($i=0;$i<$dblsz;$i++){ $add = toCharArray($dbl[$i]); for ($j=0;$j
=0; $i-=2){ $validate += $dig[$i]; } if (substr($validate, -1, 1) == '0') return 1; else return 0; } // takes a string and returns an array of characters function toCharArray($input){ $len = strlen($input); for ($j=0;$j<$len;$j++){ $char[$j] = substr($input, $j, 1); } return ($char); } ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage