Perhaps. When getting text from a form field, what is substituted for a
newline (i.e. when someone hits enter).
Jason
On Sun, 2003-07-13 at 17:21, David Otton wrote:
> On 13 Jul 2003 17:01:24 -0400, you wrote:
>
> >I'm trying to replace newlines with something else. For this example
> >I'll use <br> as the thing to replace a newline with. This is what I
> >tried and it doesn't work.
>
> nl2br() in the specific case
>
> >$article = str_replace("\n", "<br>", $article);
> >
> >What am I doing wrong? $article is the string to replace the newlines
> >in. I tried this with a period and that works as expected. Can I not
> >replace newlines this way?
>
> But in the general case, your code looks ok to me.
>
> echo (str_replace("\n", "<br>", "foo\nbar"));
>
> returns "foo<br>bar" here. Maybe $article doesn't contain what you think it
> does?
>
> (BTW, I prefer to replace "\n" with "<br>\n", but that's just a style
> thing.)
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php