You are here

function File::_next in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 modules/marcParse/php-marc.php \File::_next()
  2. 7 modules/marcParse/php-marc.php \File::_next()
  3. 7.2 modules/marcParse/php-marc.php \File::_next()

* Return the next raw MARC record * * Returns th nexts raw MARC record from the read file, unless all * records already have been read. *

Return value

string|false Either a raw record or False

1 call to File::_next()
File::next in marcParse/php-marc.php
* Return next Record-object * * Decode the next raw MARC record and return *

File

marcParse/php-marc.php, line 156

Class

File
Class File Class to read MARC records from file(s)

Code

function _next() {

  /**
   * Exit if we are at the end of the file
   */
  if ($this->pointer >= count($this->raw)) {
    return FALSE;
  }

  /**
   * Read next line
   */
  $usmarc = $this->raw[$this->pointer++];

  // remove illegal stuff that sometimes occurs between records
  // preg_replace does not know what to do with \x00, thus omitted.
  $usmarc = preg_replace("/^[\n\r]+/", "", $usmarc);

  /**
   * Record validation
   */
  if (strlen($usmarc) < 5) {
    $this
      ->_warn("Couldn't find record length");
  }
  $reclen = substr($usmarc, 0, 5);
  if (preg_match("/^\\d{5}\$/", $reclen) || $reclen != strlen($usmarc)) {
    $this
      ->_warn("Invalid record length \"{$reclen}\"");
  }
  return $usmarc;
}