It turns out that the last X in my ID is actually 2.
- 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';
- }
- }
Copy code
|