You are here

function isbn_clean_field in ISBN Field 6.0

2 calls to isbn_clean_field()
isbn_find_isbns in ./isbn.module
isbn_form_submit in ./isbn.module

File

./isbn.module, line 103
Maintains a consistant relationship between nodes and ISBNs.

Code

function isbn_clean_field($field) {
  $bad_chars = array(
    "-",
    "/",
    " ",
  );
  $isbn = strtoupper(trim(str_replace($bad_chars, "", $field)));
  if (strlen($isbn) > 9) {
    $test = substr($isbn, 10, 1);
    if (is_numeric($test)) {
      $isbn = substr($isbn, 0, 13);
    }
    else {
      $isbn = substr($isbn, 0, 10);
    }
  }
  else {
    $isbn = null;
  }
  return $isbn;
}