Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validare cui, cui validation, CUI validalas, validare CIF, CIF validation, CIF validalas
function validare_cui( $cif )
{
if (!is_numeric($cui))
return false;
// Exista CUI -uri mai scurte de 6 cifre pe care sunt valide. (Ex. 5229, 52298)
if (strlen($cui) < 4 || strlen($cui) > 10)
return false;
$cifra_control = substr($cui, -1);
$cui = substr($cui, 0, -1);
while (strlen($cui) != 9) {
$cui = '0' . $cui;
}
$_suma = $cui[0] * 7 + $cui[1] * 5 + $cui[2] * 3 + $cui[3] * 2 + $cui[4] * 1 + $cui[5] * 7 + $cui[6] * 5 + $cui[7] * 3 + $cui[8] * 2;
$suma = $_suma * 10;
$rest = fmod($suma, 11);
if ($rest == 10)
$rest = 0;
if ($rest == $cifra_control)
return true;
else
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.