// Append a new subfield to the existing set of subfields// Expected order: a-z-g$field->appendSubfield($subfield1);

// Insert a new subfield after the first subfield with code 'z'// Expected order: a-z-k-g$sf = $field->getSubfields('z');// getSubfields() always returns an array; we just want the first subfieldif (count($sf) > 0) {$field->insertSubfield($subfield2, $sf[0]);}