PATH:
opt
/
alt
/
php52
/
usr
/
share
/
pear
/
test
/
File_MARC
/
tests
--TEST-- marc_006: test read.php --SKIPIF-- <?php include('skipif.inc'); ?> --FILE-- <?php $dir = dirname(__FILE__); require 'File/MARC.php'; // Read MARC records from a stream (a file, in this case) $marc_source = new File_MARC($dir . '/' . 'example.mrc'); // Retrieve the first MARC record from the source $marc_record = $marc_source->next(); // Retrieve a personal name field from the record $names = $marc_record->getFields('100'); foreach ($names as $name_field) { // Now print the $a subfield switch ($name_field->getIndicator(1)) { case 0: print "Forename: "; break; case 1: print "Surname: "; break; case 2: print "Family name: "; break; } $name = $name_field->getSubfields('a'); if (count($name) == 1) { print $name[0]->getData() . "\n"; } else { print "Error -- \$a subfield appears more than once in this field!"; } } // Retrieve all series statement fields // Series statement fields start with a 4 (PCRE) $subjects = $marc_record->getFields('^4', true); // Iterate through all of the returned series statement fields foreach ($subjects as $field) { // print with File_MARC_Field_Data's magic __toString() method print $field; } ?> --EXPECT-- Surname: Jansson, Tove, 440 0 _aMumin-biblioteket, _x99-0698931-9
[-] marc_lint_005.phpt
[open]
[-] bad_example.xml
[open]
[-] skipif.inc
[open]
[-] marc_field_003.phpt
[open]
[-] marc_014.phpt
[open]
[-] music.xml
[open]
[+]
..
[-] example.mrc
[open]
[-] marc_016.phpt
[open]
[-] marc_xml_007.phpt
[open]
[-] marc_field_004.phpt
[open]
[-] marc_lint_001.phpt
[open]
[-] marc_004.phpt
[open]
[-] sandburg.mrc
[open]
[-] marc_002.phpt
[open]
[-] marc_field_002.phpt
[open]
[-] marc_subfield_001.phpt
[open]
[-] marc_009.phpt
[open]
[-] onerecord.xml
[open]
[-] marc_xml_009.phpt
[open]
[-] marc_lint_004.phpt
[open]
[-] bigarchive.xml
[open]
[-] marc_015.phpt
[open]
[-] marc_xml_16642.phpt
[open]
[-] marc_xml_008.phpt
[open]
[-] marc_xml_002.phpt
[open]
[-] marc_subfield_002.phpt
[open]
[-] marc_003.phpt
[open]
[-] sandburg.xml
[open]
[-] marc_018.phpt
[open]
[-] music.mrc
[open]
[-] marc_lint_002.phpt
[open]
[-] marc_010.phpt
[open]
[-] marc_006.phpt
[open]
[-] marc_xml_006.phpt
[open]
[-] marc_017.phpt
[open]
[-] marc_lint_003.phpt
[open]
[-] marc_field_001.phpt
[open]
[-] marc_xml_rsinger.phpt
[open]
[-] marc_008.phpt
[open]
[-] marc_007.phpt
[open]
[-] marc_xml_005.phpt
[open]
[-] marc_012.phpt
[open]
[-] marc_16783.phpt
[open]
[-] bad_example.mrc
[open]
[-] marc_005.phpt
[open]
[-] marc_xml_001.phpt
[open]
[-] marc_xml_003.phpt
[open]
[-] marc_record_001.phpt
[open]
[-] marc_001.phpt
[open]
[-] marc_019.phpt
[open]
[-] marc_xml_004.phpt
[open]
[-] marc_013.phpt
[open]
[-] xmlescape.mrc
[open]
[-] camel.mrc
[open]
[-] marc_011.phpt
[open]