CNP
Posted on 10/04/2006
/*
Validare de CNP
1) se calculeaza suma
s:=c(1)*2+c(2)*7+c(3)*9+c(4)*1+c(5)*4+c(6)*6+c(7)*3+c(8)*5+c(9)*8+c(10)*2+c(11)*7+c(12)*9
2) faci impartirea
rest=s%11
3) dupa cum:
- rest<10 at c(13)=rest
sau
- rest=10 at c(13)=1
*/
$cnp = "";
if ( calcCNP ( $cnp ) ) {
echo $cnp." e valid";
} else {
echo $cnp." e invalid";
}
function calcCNP ($cnp) {
if ( strlen ($cnp) != 13 ) {
return FALSE;
}
$s = $cnp{0}*2+$cnp{1}*7+$cnp{2}*9+$cnp{3}*1+$cnp{4}*4+$cnp{5}*6+$cnp{6}*3+$cnp{7}*5+$cnp{8}*8+$cnp{9}*2+$cnp{10}*7+$cnp{11}*9;
$rest = $s%11;
if ( $cnp{12} == $rest ) {
return TRUE;
} else {
return FALSE;
}
}
Validare de CNP
1) se calculeaza suma
s:=c(1)*2+c(2)*7+c(3)*9+c(4)*1+c(5)*4+c(6)*6+c(7)*3+c(8)*5+c(9)*8+c(10)*2+c(11)*7+c(12)*9
2) faci impartirea
rest=s%11
3) dupa cum:
- rest<10 at c(13)=rest
sau
- rest=10 at c(13)=1
*/
$cnp = "";
if ( calcCNP ( $cnp ) ) {
echo $cnp." e valid";
} else {
echo $cnp." e invalid";
}
function calcCNP ($cnp) {
if ( strlen ($cnp) != 13 ) {
return FALSE;
}
$s = $cnp{0}*2+$cnp{1}*7+$cnp{2}*9+$cnp{3}*1+$cnp{4}*4+$cnp{5}*6+$cnp{6}*3+$cnp{7}*5+$cnp{8}*8+$cnp{9}*2+$cnp{10}*7+$cnp{11}*9;
$rest = $s%11;
if ( $cnp{12} == $rest ) {
return TRUE;
} else {
return FALSE;
}
}



















![Cheile Gradistei [Mobile upload 2007/12/20 15:40:54]](/images/upload/1/t-1048.jpg)
![Salina Praid [Mobile upload 2007/09/22 04:23:46]](/images/upload/1/t-1047.jpg)
![Transfagarasan [Mobile upload 2007/07/23 06:14:13]](/images/upload/1/t-1031.jpg)
![Balea Lac 2 [Mobile upload 2007/07/23 05:16:33]](/images/upload/1/t-1030.jpg)
![Voineasa [Mobile upload 2007/07/21 12:42:12]](/images/upload/1/t-1029.jpg)
![Omg [Mobile upload 2007/07/20 10:18:23]](/images/upload/1/t-1028.jpg)
![Krka National Park [Mobile upload 2007/06/15 11:02:18]](/images/upload/1/t-1022.jpg)
![Fia Gt3 [Mobile upload 2007/06/01 10:48:18]](/images/upload/1/t-1021.jpg)
![In Drum Spre Bulgaria [Mobile upload 2007/06/01 10:47:26]](/images/upload/1/t-1020.jpg)











