Jump to content

Convert lines to breaks?


reportingsjr

Recommended Posts

How could I do something like this forum, where if you hit enter and submit a post the enter stays, and everything doesnt just get reduced to one space? I have already tried the html <pre> tag but that seems to double all spaces for me... Odd! And it wouldnt be nl2br I dnot think because im not using \n or a text file.. Any thoughts?

Link to comment
Share on other sites

The question has already been answered, but I do have my 2 cents.I tend to use regex instead of nl2br. The function is cool and all, but does tend to put a lot of linebreaks where it shouldn't belong intuitively if you allow html in the input. I make an expression that changes \n to <br /> in all situations except where it occurs before and after the end tag for block elements.

Link to comment
Share on other sites

Yeah, I used to say use regex. But they kept telling me it used extra overhead, which you dont want! Overhead means you use extra resources, in this case the regex engine (yes, it has its own engine...). So for this I say just use nl2br!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...