hanshuai0921
public static function check_card($no)
    {
        $return = false;
        $arr_no = str_split($no);

        $last_n = $arr_no[count($arr_no)-1];

        krsort($arr_no);

        $i = 1;
        $total = 0;

        foreach ($arr_no as $n){

            if($i%2==0){

                $ix = $n*2;

                if($ix>=10){

                    $nx = 1 + ($ix % 10);
                    $total += $nx;

                }else{

                    $total += $ix;

                }

            }else{

                $total += $n;

            }

            $i++;
        }

        $total -= $last_n;
        $total *= 9;

        if($last_n == ($total%10)){
            $return = true;
        }
       // var_dump($return);
        return $return;
    }

这里验证的前提需要保证银行卡号不能为空和0

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-02-23
  • 2021-11-23
  • 2021-12-06
  • 2021-12-26
  • 2022-02-07
猜你喜欢
  • 2021-12-19
  • 2022-02-07
  • 2022-01-01
  • 2022-02-07
  • 2022-02-07
  • 2021-11-29
  • 2022-02-07
相关资源
相似解决方案