您现在的位置是:生成校验位(银行卡最后一位)
生成校验位(银行卡最后一位)
** 注意:$s必须全部为数字
// 计算校验位 function encodeCode($s) { $a = $b = $c = $d = $e = 0; $s = str_split($s); $count = count($s); for( $i = 1; $i <= $count; $i++ ) { $sc = intval($s[$i - 1]); if( $i <= $count && $i % 2 == 0 ) { $a += $sc; } elseif( $i <= $count - 1 && $i % 2 == 1 ) { $b += $sc; } } $c = $a * 3; $d = $b + $c; if( $d % 10 == 0 ) { $e = $d - $d; } else { $e = $d + (10 - $d % 10) - $d; } return $e; }
站长简介
分类
最新文章
热门文章
- 微信支付退款结果通知解密
- 到ICANN投诉三五互联获取域名转移密码成功
- Linux修改密码提示passwd /usr/share/cracklib/pw_dict: error reading header
- {"errcode":45047,"errmsg":"out of response count limit hint]"}
- 微信html弹出点击右上角分享到朋友圈
- Apache禁用TRACE Method和添加X-frame-options响应头
- PHP将B转换为KB、MB、GB
- 构建微信公众号被动回复image图片消息xml
- mysqld_safe Number of processes running now
- CentOS使用chkconfig提示systemctl enable xxxx.service