function isbn_check_13 in ISBN Field 6.0
Same name and namespace in other branches
- 7 isbn.module \isbn_check_13()
2 calls to isbn_check_13()
- isbn_build_isbns in ./isbn.module
- isbn_form_submit in ./isbn.module
File
- ./isbn.module, line 161
- Maintains a consistant relationship between nodes and ISBNs.
Code
function isbn_check_13($isbn) {
$weight = 1;
for ($i = 0; $i < 12; $i++) {
$digit = substr($isbn, $i, 1);
$total = $total + $digit * $weight;
if ($weight == 1) {
$weight = 3;
}
else {
$weight = 1;
}
}
$remainder = $total % 10;
$check = 10 - $remainder;
if ($check == 10) {
$check = '0';
}
return $check;
}