Jump to content

retaining spaces from textareas to database


Vivid Lust

Recommended Posts

Hi all,

 

How can I retain spaces which users make in textareas when saved in a database in a field which is ummm, set as "text".

 

Say they press enter a couple of times... how could I retain that?? At the moment its just getting rid of two spaces or more...

 

Thanks.

your problem is not the data being saved to the database, it's that when a browser renders html it skips multiple subsequent spaces and all line returns. You can maintain line breaks with nl2br() to change "enter hits" (line breaks) to <br /> tags that a browser will actually render. As for multiple subsequent spaces... I guess you could change all spaces to   but that sounds like a waste of bandwidth and render time.

 

alternatively you could encase it all in <pre></pre> tags

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.