Re: Re: Replacing newlines (\n) with smething else

From: Date: Sun, 13 Jul 2003 21:17:00 +0000
Subject: Re: Re: Replacing newlines (\n) with smething else
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-155021@lists.php.net to get a copy of this message
I did not know about nl2br. Thanks. But what if say I want to replace a newline with something else, say </p><p>. How would I do that? Jason On Sun, 2003-07-13 at 17:09, J. Cox wrote: > "Jason Giangrande" <jason@giangrande.org> wrote in message > news:1058130084.12830.5.camel@dragon.giangrande.org... > > Hi, > > > > 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. > > > > $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? > > why not just: > > $article = nl2br($article); > > -- > J. Cox > http://www.xaraya.com > > >

« previous php.general (#155021) next »