cl2000
cl2000

Reputation: 1

Spaces in a text area

I have a textarea where the user can input text. If the user types and goes to a new line, and continues writing text, or starts a new paragraph, when the content of the textarea is sent by a form using $_POST, and printed again, the content has no spaces or new lines showing in it. It displays as one chunk of text. Can anyone help out?

Upvotes: 0

Views: 475

Answers (1)

John Conde
John Conde

Reputation: 219834

HTML displays multiple spaces and line breaks as one space. This means you will need to do your own formatting to make it display as in the <textarea>. You can use nl2br() to convert new lines into <br> and replace spaces with nbsp; using str_replace() or similar functions. You could also wrap the text in <pre> tags as well.

Upvotes: 1

Related Questions