We have a MySQL database with records in plain text. To format newlines as BR-tags, we use the php nl2br-function. Now we want to start using FCKeditor, but also want to be able to use the old records. This gives problems with some tags and the formatting of the html FCKeditor does, because <BR> are added at each newline. Is it possible to delete the html-formatting and write all code the editor generates on one line?
Thu, 04/15/2004 - 00:42
#1
RE: Formatting of HTML
However, it appears to me that you're asking whether you can make the editor save everything to one line, and it already does that, as I said above.
RE: Formatting of HTML
I use the latest version of FCK-editor.
RE: Formatting of HTML
However, in the case you cannot live without nl2br, you could replace the chr(10) or chr(13) with str_replace() or similar functions before inserting the string into you db.
Markus
RE: Formatting of HTML
But now I'm thinking...
How about to make a $newText = explode("\n", $text);
And then a for to put all lines in the value...
for ($i = 0; $i < count($newText); $i++) {
$oFCKeditor->Value .= $newText[$i];
}
I can't test it, but might works...
RE: Formatting of HTML
I don't think that's the solution - as far as I can see, you populate the FCKeditor with 1 line containing all the code. But what happens if the user edits or inserts something? I guess that you'll get new lines again.
It can only work if you change the form results, i.e. the variable you get on the processing page. And there, just use the str_replace() function of php, you won't need a complicated explode & for loop.
Hope that helps!
Markus