1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
$CP = '6605129N';
$LETTRE = array('A','B','C','D','E','F','G',
'H','I','J','K','L','M','N',
'O','P','Q','R','S','T','U',
'V','W','X','Y','Z');
$let = array();
$let = NULL;
for($i = 0; $i<=25; $i++){
echo $let[] = $LETTRE[$i];
}echo "<br>";
$nb_lettre = strlen($CP);
if( $nb_lettre == 8)
{
$num= substr($CP,0,7)."<br>";
$l = substr($CP,7,8)."<br>";
}
if($nb_lettre == 9)
{
$num= substr($CP,1,7);
$l = substr($CP,8,9);
}
$modulo = ($num % 23)."<br>";
echo $k = $num - $modulo."<br>";
echo "m".$m = (int)($num / 23)."<br>";
echo "j".$j = ($num -($m * 23) + 1)."<br>";
if($LETTRE[$j] == $l){
$correct = 1;
}
else{
$correct = 0;
} |
Partager