Objective
Bank gold, Visa and MasterCard, UnionPay brand, if it is a credit card or quasi-credit card, it must be a 16-digit card number. Debit cards can range from 16-19 digits.
American Express Card is a 15-digit card number regardless of gold or Platinum card.
16-19-bit card number check digit is calculated by Luhm check method
Check mode of bank card luhm check
- The 15-bit card number without the check digit is numbered from right to 1 to 15, and the number on the odd digit is multiplied by 2
- Add all 10 bits of the singular product, plus the numbers on all even digits
- The addition and calibration potentials are divisible by 10.
1<?PHP2 /*3 The 16-19-bit card number check digit is calculated using the Luhm check method:4 1, the 15-digit card number without the check digit is numbered 1 to 15 from the right, and the number on the odd digit is multiplied by 25 2, add all 10 bits of the singular product, plus the numbers on all even digits6 3, the addition and calibration potentials are divisible by 10. 7 */8 functionLuhm ($s) {9 $n= 0;Ten for($i=strlen($s);$i>= 1;$i--) { One $index=$i-1; A //even digits - if($i% 2==0) { - $n+=$s{$index}; the}Else{//Odd digits - $t=$s{$index} * 2; - if($t> 9) { - $t= (int) ($t/10) +$t%10; + } - $n+=$t; + } A } at return($n% 10) = = 0; - } - - $r= Luhm (' 6225881414207430 '); - Var_dump($r); -?>
PHP Bank card Check