correccion de digito verificador

parent 49390613
......@@ -104,29 +104,11 @@ class UsuarioMcafee extends BaseUsuarioMcafee {
}
}
public function getDv() {
$x = 2;
$sumatorio = 0;
for ($i = strlen($rut) - 1; $i > 0; $i--) {
if ($x > 7) {
$x = 2;
}
$sumatorio = $sumatorio + ($rut[$i] * $x);
$x++;
}
$digito = bcmod($sumatorio, 11);
$digito = 11 - $digito;
switch ($digito) {
case 10:
$digito = "K";
break;
case 11:
$digito = "0";
break;
}
return $digito;
public function getDv($r) {
$s = 1;
for ($m = 0; $r != 0; $r /= 10)
$s = ($s + $r % 10 * (9 - $m++ % 6)) % 11;
return chr($s ? $s + 47 : 75);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment