You are here

function bad_ISN_char_count in ISBN Field 6

4 calls to bad_ISN_char_count()
generate_ISN_corrections in ./isbn.inc
ISBN_classifier in ./isbn.inc
ISN_checksum_OK in ./isbn.inc
ISN_classifier in ./isbn.inc

File

./isbn.inc, line 77

Code

function bad_ISN_char_count($proto_string) {
  $count = 0;
  for ($i = 0; $i < strlen($proto_string); $i++) {
    $c = $proto_string[$i];
    if ($c == '-') {
      continue;
    }
    if ($c < '0' || $c > '9') {
      $count++;
    }
  }
  if ($c == 'X' || $c == 'x') {
    return $count - 1;

    // adjustment for a check digit
  }
  else {
    return $count;
  }
}