Re: str_replace to replace /n with <p> not having desired effect.

From: Date: Thu, 19 Feb 2004 15:59:33 +0000
Subject: Re: str_replace to replace /n with <p> not having desired effect.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-178253@lists.php.net to get a copy of this message
Single quotes don't work for the escape characters. Use double quotes around the str_replace where there is a \n. On Thu, 2004-02-19 at 10:52, Dave G wrote: > PHP Listers, > I am trying to use str_replace to format text taken from a MySQL > TEXT field and make it so that it is compatible with my CSS formatting. > Essentially, I want to ensure that new lines are replaced with <p> tags > with the appropriate CSS class designation. > The code I have created with assistance from information found > on the web, looks like this: > > $charInfoCss = '<p class="content">' . str_replace('\n', > '</p>\n<p > class="content">\n', $charInfo[introE]) . '</p>'; > > The output looks like this: > <p class="content">Blah blah blah blah. > Another line of blah blah blah. > A third line of blah blah blah.</p> > > The output I desire is this: > <p class="content">Blah blah blah blah.</p> > <p class="content">Another line of blah blah blah.</p> > <p class="content">A third line of blah blah blah.</p> > > How do I correct my code to accomplish this? > > Thank you. > > -- > Yoroshiku! > Dave G ml@autotelic.com -- Adam Voigt adam@kotisprop.com

« previous php.general (#178253) next »