codepad.viper-7.com
Script:
(hide)
Author
unknown
Size:
1292 b
Created:
12/12/2012 11:32am
Version:
5
Hits:
24
Render Time:
0.00 ms
PHP Version
trunk-dev
5.5-dev
5.4.9
5.4-dev
5.3.19
5.3.10
5.3-dev
5.2.17
Output:
HTML
(hide)
Code:
(hide)
<?php
$record = array('leader' => '01220nam 2200265 4500', 'fields' => array(array('001' => 'ocm00000197'),array('005'=>'19880526181046.0'),array('245'=> array('ind1' => 1, 'ind2'=> '', 'subfields'=> array(array('a' => 'SUBFIELD a!!!'),array('b' => 'SUBFIELD b!!!'))))));
print_r($record);
function getSubfield($record, $in_field, $in_subfield) {
foreach ($record['fields'] as $key => $field) {
$marc_keys = array_keys($field);
$marc_field = $marc_keys[0];
// Test if the key you found is the one you want (which is the $in_field param)
if ($marc_field == $in_field) {
foreach ($field[$marc_field]['subfields'] as $subkey => $subfield) {
$sf_keys = array_keys($subfield);
$sf_identifier = $sf_keys[0];
// And match the subfield to the function param $in_subfield
if ($sf_identifier == $in_subfield) {
// Congratulations Arthur, you found the grail....
// Return it...
return $subfield[$sf_identifier];
}
}
}
// Otherwise, keep looping until you find the one you need...
}
}
echo '<h2> Calling for 245 subfield b</h2>';
echo '<h2>The string you want is:</h2>';
echo getSubfield($record, '245','b');
User
Create Account
Log In
Views
Request Headers
Response Headers
Response Body
Opcodes
Profile
Call Graph
Controls
New Paste
Paste History
unknown:
untitled
unknown:
untitled
unknown:
untitled
unknown:
untitled
unknown:
untitled
unknown:
untitled
unknown:
untitled
unknown:
untitled