Re: replacing \n with <br>
| From: | Robert Cummings | Date: | Fri, 06 Sep 2002 16:34:24 +0000 |
| Subject: | Re: replacing \n with <br> | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115515@lists.php.net to get a copy of this message | ||
David T-G wrote:
>
> 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.
*ACK* Stoopid microsoft... it's the "\r" character I bet.
Cheers,
Rob.
--
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer |
:----------------------------------------------:
| Mail : mailto:robert.cummings@webmotion.com |
| Phone : (613) 731-4046 x.109 |
:----------------------------------------------:
| Website : http://www.webmotion.com |
| Fax : (613) 260-9545 |
`----------------------------------------------'