Actually on second thought... and I don't know why I went with the
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.

Cheers,
Rob.


David T-G wrote:
> 
> Rob, et al --
> 
> ...and then Robert Cummings said...
> %
> % David T-G wrote:
> % >
> % I've never had problems with doing:
> %
> %     $foo = "I don't like\nnewlines";
> %
> %     $foo = ereg_replace( "\n", '<br />', $foo );
> 
> I'm afraid I do.  Given my code
> 
>       $fin = stripslashes(${base64_encode($k)}) ;       ###
>       print "\$fin is .$fin.<BR>\n";    ###
>       $fout = ereg_replace("\n","<br>",$fin) ;
>       print "and \$fout is .$fout.<BR>\n";      ###
> 
> (ignore the scary base64 stuff :-) I get
> 
>   $fin is .This is the first line. Here is the second line..
>   and $fout is .This is the first line.
>   Here is the second line..
> 
> in my browser and
> 
>   $fin is .This is the first line.
>   Here is the second line..<BR>
>   and $fout is .This is the first line.
>   <br>Here is the second line..<BR>
>   <br><br>
> 
> in my browser's source window.  The newlines are still there.
> 
> Any thoughts?
> 
> %
> % Cheers,
> % Rob.
> 
> Thanks & HAND
> 
> :-D
> --
> David T-G                      * It's easier to fight for one's principles
> (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
> (work) [EMAIL PROTECTED]
> http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
> 
>   
>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature

-- 
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer  |
:----------------------------------------------:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109                 |
:----------------------------------------------:
| Website : http://www.webmotion.com           |
| Fax     : (613) 260-9545                     |
`----------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to