Reputation: 5148
I have no expreience in ASP codes and I couldn't change back this function to a PHP one
function MELLICODE(CODE: STRING): Boolean;
var a,b,c : integer;
begin
A:=strtoint(CODE[10]);
B:=strtoint(CODE[1])*10 + strtoint(CODE[2])*9 +
strtoint(CODE[3])*8 + strtoint(CODE[4])*7 + strtoint(CODE[5])*6 +
strtoint(CODE[6])*5 + strtoint(CODE[7])*4 + strtoint(CODE[8])*3 +
strtoint(CODE[9])*2;
C:=b-(b div 11)*11;
If (c=0) and (a=c) then
MELLICODE:=TRUE
else if (c=1) and (a=1) then
MELLICODE:=TRUE
else if (c>1) and (a=abs(c-11)) then
MELLICODE:=TRUE
else
MELLICODE:=FALSE;
This is a code generator and it will produce a code with 10 numbers.
I know that this is asking a lot but I tried so much but can't understand the language.
Upvotes: 0
Views: 100
Reputation: 410
I haven't used ASP for years. I'm sure it's not complete but can help you.
function mellicode( $code ) {
$a = intval( $code[9] );
$b = ( intval( $code[0] ) * 10 ) + ( intval( $code[1] ) * 9 ) + ( intval( $code[2] ) * 8 ) + ( intval( $code[3] ) * 7 ) + ( intval( $code[4] ) * 6 ) + ( intval( $code[5] ) * 5 ) + ( intval( $code[6] ) * 4 ) + ( intval( $code[7] ) * 3 ) + ( intval( $code[8] ) * 2 );
$c = $b - ( $b % 11 )*11;
if( $c == 0 AND $a == $c )
return TRUE;
elseif( $c == 1 AND $a == 1 )
return TRUE;
elseif( $c > 1 AND $a == abs( $c - 11 ) )
return TRUE;
else
return FALSE;
}
Upvotes: 1