php身份证校验码的计算例子
下面来给各位同学介绍一个php身份证校验码的计算例子,希望本函数代码能帮助到各位同学哦。
例子
<?php public function id_verify($my_id) { $coefficient = array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2); $remainder_map = array(1,0,'X',9,8,7,6,5,4,3,2); $count = 0; for ($i=0; $i < 17; $i++) { $count += $my_id[$i] * $coefficient[$i]; } $remainder = $count % 11; if ($my_id[17] == $remainder_map[$remainder]){ echo 'true'; }else{ echo 'false'; } } ?>
使用方法很简单
$body = '44010221990101001';
id_verify($my_id) //就会有结果输出的哦
文章网址:http://www.phprm.com/code/64622.html
随意转载^^但请附上教程地址。