Re: replacing \n with <br>
| From: | David T-G | Date: | Fri, 06 Sep 2002 16:24:24 +0000 |
| Subject: | Re: replacing \n with <br> | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115514@lists.php.net to get a copy of this message | ||
Rob, et al --
..and then Robert Cummings said...
%
% Actually on second thought... and I don't know why I went with the
*grin*
% crowd in the first place... I do the following:
%
% $foo = "I don't like\nnewlines";
%
% $foo = str_replace( "\n", '<br />', $foo );
%
% That one work for you? It's more efficient too.
Actually, no. I thought about listing all of the things I had tried (and
ereg_replace wasn't one of 'em) in my post but didn't want to clutter
things up. I've tried str_replace, preg_replace, and now ereg_replace,
and have tried working on the function extraction of the data directly as
well as the $fin and $fout separation. I always have the newline left
behind.
I'm a [rusty] perl guy, and so I keep wanting to know what's the magic
variable in PHP to set to make it eat entire paragraphs, like $/ or such
in perl (there's where the rusty part comes in!). If these functions are
just operating on a single line then the newline(s) won't get eaten.
%
% Cheers,
% Rob.
Thanks & HAND
:-D
--
David T-G * It's easier to fight for one's principles
(play) davidtg@justpickone.org * than to live up to them. -- fortune cookie
(work) davidtgwork@justpickone.org
http://www.justpickone.org/davidtg/ Shpx gur
Pbzzhavpngvbaf Qrprapl Npg!