elements in post bodies and extended bodies. * It does not handle comments. Those were too much of a pain to worry about. * * This script is not guaranteed to be perfect and may mangle your content, format your * hard drive, or break into your fridge and steal your salami. Use at your own risk. */ $inputFile = "siwp.txt"; $outputFile = "siwp_output.txt"; $txt = file_get_contents($inputFile); // This is the delimiter between post properties (not posts!). $lines = explode("\n-----\n", $txt); $newTxt = ""; foreach($lines as $line) { if (substr($line, 0, 5) == "BODY:") { $snip = replaceLineBreaks($line, "BODY:"); } else if (substr($line, 0, 14) == "EXTENDED BODY:") { $snip = replaceLineBreaks($line, "EXTENDED BODY:"); } else { $snip = $line; } $newTxt .= $snip . "\n-----\n"; } file_put_contents($outputFile, $newTxt); function replaceLineBreaks($input, $prefix) { $converted = substr($input, strlen($prefix) + 1); // the +1 is for the line break $converted = str_replace(array("\r\n", "\r", "\n"), "
", $converted); $converted = $prefix . "\n" . $converted; return $converted; } ?>