why not display the results on a <div>
perhaps or a <p>
??
I think the <br />
tag is what you want in this case. Newline characters like \n and \r don't do anything in HTML - all whitespace, including newlines, is ignored. The <br />
tag is essentially the HTML equivalent - it stands for "break". I don't know too much about PHP specifically, so I don't know why it's putting the <br />
there for you automatically, but that's the correct HTML for what you're describing.
Technically, there are better ways to format your output then using those tags, but that's more of an advanced topic. If you are a bit new to this, like you said, then just get it working this way for now, and then maybe sometime down the road you can learn about proper semantic HTML markup, CSS styling, etc.
I believe \n
should work. Perhaps you do not have or have an incorrect doctype.
Example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
If all else, I like lock's answer. You could us a <div>
and you could even style it to look similar to a <textarea>
(or even better!)
I'll preface this by saying I use Blogger not Wordpress but I imagine there are similarities. In Blogger there is a setting to convert line breaks into <br>
tags. I guess it's convenient if you're not putting code snippets and the like in (if you're blogging about cats or something) but not so much for programming. I had to turn it off and put in my paragraph tags, etc manually.
Here is one less than ideal solution, which also mentions the issue of Wordpress inserting <br>
tags in forms.
It took some looking, but after some time I was able to pinpoint these two locations (lines 154 & 165 - WP 2.8) in the wp-includes/formatting.php file.
154 $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n"; //<-- before
154 $pee .= trim($tinkle, "\n") . "\n"; //<-- after
165 $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks <-- before
165 $pee = preg_replace('|(?<!<br />)\s*\n|', "\n", $pee); // optionally make line breaks <-- after
This took care of the paragraph and and break tags in my textarea field.