Forum Moderators: open
In other words,
This is one line
And this is another
becomes
This is one lineAnd this is another
I think this is an HTML problem, not a PHP problem. However, I wonder whether PHP interprets the Windows return [CR][LF] as two new lines and then writes it as [LF][LF] which Windows then turns into [CR][LF][CR][LF]?
Tom
A breakdown of the working script:
The text processing sits in a function at the top of the script.
If the incoming text is new - stripslashes() and echo into the textarea.
else (if it's been edited and is returning) strip_tags(), stripslashes(), and re-process. Then echo to the textarea.
The processing:
stripslashes(),
changes \n to <br>,
<br>[[:space:]]<br> to <p>,
and \t to 9
(in that order).
So now I just strip out \r on save and even on the Windows machine it saves in "*nix format". That seems to work fine.
into an array and then checking each element to see if it only contains a \n
I didn't try that, but I'm guessing that it wouldn't work because each line would contain \n\r at a minumum.
My solution to this was simply to strip_tags()
I think that's a solution to a different problem. My stuff was displaying just fine in a browser since the whitespace gets ignored. So there was no issue with <br> and such. It's just that the raw HTML was getting unexpected linefeeds and I think it's just the weirdness of Windows (and I want this to run on both Win and Lin).
Tom