PHP Bank card Check

Source: Internet
Author: User

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
    1. 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
    2. Add all 10 bits of the singular product, plus the numbers on all even digits
    3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.