Last active
April 11, 2019 14:44
-
-
Save zrkb/747866c47f47762989caf0fa7707160b to your computer and use it in GitHub Desktop.
Digito Verificador de Ruc Paraguayo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function digito_verificador($ci, $baseMax = 11) | |
| { | |
| $resultado = 0; | |
| $index = 0; | |
| for ($rucIndex = strlen($ci) - 1; $rucIndex >= 0; $rucIndex--) { | |
| $resultado += (int) $ci[$rucIndex] * ($index + 2); | |
| $r = $resultado % $baseMax; | |
| $index++; | |
| }; | |
| $verificador = $r > 1 ? $baseMax - $r : 0; | |
| return $verificador; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment