Page 1 of 1

New Line Question

Posted: Sun Oct 13, 2002 10:32 pm
by Sevengraff
Ok, I made a simple text-based news script, and it keeps news posts as one line on a text file. This means that if i hit return in the text area when i submit the news, it will mess everything up. Is there anyway I can not have this happen?

Posted: Sun Oct 13, 2002 10:38 pm
by volka

Posted: Sun Oct 13, 2002 10:53 pm
by Sevengraff
i wish that helped.
nl2br does replace a new line with a <br />, wich is helpful, except that it puts the remaing text on a new line. and with str_replace, i dont know what to replace. what is the character?

Posted: Sun Oct 13, 2002 10:59 pm
by volka
take a look at the user contributed notes
really do as solutions already habe been provided there

Posted: Mon Oct 14, 2002 4:56 pm
by hob_goblin
just make a new function then, and apply it to the input

say $post contained the information you wanted on one line, then just do

Code: Select all

str_replace("\n", "<br/>", $post);
then that would work. but what i'd do, is right before it's printing, cause the source would be really cluttered if everything was on one line is:

Code: Select all

echo str_replace("<br/>", "/n<br/>", $post);