", $sections[$i]); $thebit=" " . $thisbits[0]; if (strpos($thebit, ' old_label="') !== false && strpos($thebit, ' label="') !== false && strpos($thebit, ' role="paragraph"') !== false) { if (str_replace("]","\\]",explode('"',explode(' old_label="', $thebit)[1])[0]) != "") { $csvout.=$delim . "," . explode('"',explode(' old_label="', $thebit)[1])[0] . ",," . explode('"',explode(' label="', $thebit)[1])[0]; $kshout.=$delim . "cat " . $indexfilecalled . " | sed '/\\" . str_replace("]","\\]",explode('"',explode(' old_label="', $thebit)[1])[0]) . "/s//\\" . str_replace("]","\\]",explode('"',explode(' label="', $thebit)[1])[0]) . "/g' > " . str_replace(".XML",".XXX",str_replace(".xml",".xxx",$indexfilecalled)) . " ; rm -f " . $indexfilecalled . " ; cat " . str_replace(".XML",".XXX",str_replace(".xml",".xxx",$indexfilecalled)) . " > " . $indexfilecalled . " ; "; $delim="\n"; } } } } file_put_contents("tr_mapping.csv", $csvout); file_put_contents("tr_mapping.ksh", $kshout); ?>