Skip to content

Instantly share code, notes, and snippets.

@yeknava
Created February 24, 2016 12:08
Show Gist options
  • Save yeknava/765a5830e08da285becf to your computer and use it in GitHub Desktop.
Save yeknava/765a5830e08da285becf to your computer and use it in GitHub Desktop.
$ncode = '0011111111';
$ncodeArray = str_split($ncode);
$sum = 0;
for($i=0; $i<10; $i++) {
$sum = intval($ncodeArray[$i])*($i+1);
}
$mod11 = $sum%11;
if($mod11 < 2) {
if(intval($mod11) === intval($ncodeArray[9])) {
return true;
} else {
return false;
}
} else {
if(intval($ncodeArray[9]) === (11-$mod11)) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment