Home > php教程 > PHP源码 > body text

php身份证校验码的计算例子

WBOY
Release: 2016-06-08 17:21:40
Original
1257 people have browsed it

下面来给各位同学介绍一个php身份证校验码的计算例子,希望本函数代码能帮助到各位同学哦。

<script>ec(2);</script>

例子

 代码如下 复制代码

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          
        $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) //就会有结果输出的哦

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!