File_MARC
[ class tree: File_MARC ] [ index: File_MARC ] [ all elements ]

Source for file read.php

Documentation is available at read.php

  1. <?php
  2.  
  3. require 'File/MARC.php';
  4.  
  5. // Read MARC records from a stream (a file, in this case)
  6. $marc_source = new File_MARC('example.mrc');
  7.  
  8. // Retrieve the first MARC record from the source
  9. $marc_record $marc_source->next();
  10.  
  11. // Retrieve a personal name field from the record
  12. $names $marc_record->getFields('100');
  13.  
  14. foreach ($names as $name_field{
  15.     // Now print the $a subfield
  16.     switch ($name_field->getIndicator(1)) {
  17.     case 0:
  18.         print "Forename: ";
  19.         break;
  20.  
  21.     case 1:
  22.         print "Surname: ";
  23.         break;
  24.  
  25.     case 2:
  26.         print "Family name: ";
  27.         break;
  28.     }
  29.  
  30.     $name $name_field->getSubfields('a');
  31.  
  32.     if (count($name== 1{
  33.         print $name[0]->getData("\n";
  34.     else {
  35.         print "Error -- \$a subfield appears more than once in this field!";
  36.     }
  37. }
  38.  
  39. print "\nPrint all series statement fields (4xx):\n";
  40. // Retrieve all series statement fields
  41. // Series statement fields start with a 4 (PCRE)
  42. $subjects $marc_record->getFields('^4'true);
  43.  
  44. // Iterate through all of the returned series statement fields
  45. foreach ($subjects as $field{
  46.     // print with File_MARC_Field_Data's magic __toString() method
  47.     print $field;
  48. }
  49.  
  50. print "\n";
  51.  
  52. ?>

Documentation generated on Wed, 13 Nov 2019 12:37:08 -0500 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.