')) { $s = strip_tags($buffer); $a = explode(' ', $s); foreach ($keywords as $key => $value) { if ($a[0] == $key) { // format output line 'nicely' // need to remove original line feed and replace with our own // if not then our closing tag is at the start of the next line in the output instead of the end of this line // while valid XML this is extremely confusing for the human reader! // let's keep it simple - all of the div on one line $buffer = ''.rtrim($buffer).''."\n"; } } } fwrite($fout, $buffer); } echo "Processed input\n"; /** * close down script */ fclose($fin) or exit("Failed to close input xml file: {$fn_in} \n"); fclose($fky) or exit("Failed to close input text file: {$fn_ky} \n"); fclose($fout) or exit("Failed to close output text file: {$fn_out} \n"); echo "Goodbye from apply_paragraph_types with TEI div tags\n"; ?>