You are here

function Record::ffield in Bibliography Module 6

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

* Formatted representation of Field * * Format a Field with a sprintf()-like formatting syntax. The formatting * codes are the names of the subfields of the Field. *

Parameters

string Field name: * @param string Format string * @return string|false Return formatted string if Field exists, otherwise False

File

marcParse/php-marc.php, line 607

Class

Record
Record Class Create a MARC Record class

Code

function ffield($tag, $format) {
  $result = "";
  if ($field = $this
    ->field($tag)) {
    for ($i = 0; $i < strlen($format); $i++) {
      $curr = $format[$i];
      if ($curr != "%") {
        $result[] = $curr;
      }
      else {
        $i++;
        $curr = $format[$i];
        if ($curr == "%") {
          $result[] = $curr;
        }
        else {
          $result[] = $field
            ->subfield($curr);
        }
      }
    }
    return implode("", $result);
  }
  else {
    return false;
  }
}