[PHP] replacing \n with br

2002-09-06 Thread David T-G
Hi, all -- I have a php script which writes comments out to a file in the format field@@comment field@@comment ... and everything has worked delightfully -- until someone put in a newline in one of the items and now we have field@@com ment field@@comment ... and things break.

Re: [PHP] replacing \n with br

2002-09-06 Thread Robert Cummings
David T-G wrote: I've never had problems with doing: $foo = I don't like\nnewlines; $foo = ereg_replace( \n, 'br /', $foo ); Cheers, Rob. Hi, all -- I have a php script which writes comments out to a file in the format field@@comment field@@comment ... and

Re: [PHP] replacing \n with br

2002-09-06 Thread N. Pari Purna Chand
Bothe of us got the same problem at same time :-) - Original Message - From: David T-G [EMAIL PROTECTED] To: PHP General list [EMAIL PROTECTED] Sent: Friday, September 06, 2002 9:28 PM Subject: [PHP] replacing \n with br -- PHP General Mailing List (http://www.php.net

Re: [PHP] replacing \n with br

2002-09-06 Thread David T-G
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)}) ;

Re: [PHP] replacing \n with br

2002-09-06 Thread Robert Cummings
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 --

Re: [PHP] replacing \n with br

2002-09-06 Thread David T-G
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

Re: [PHP] replacing \n with br

2002-09-06 Thread Robert Cummings
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

Re: [PHP] replacing \n with br

2002-09-06 Thread Brent Baisley
Why not just use the nl2br() function? It's a lot easier that using any replace function you build yourself. On Friday, September 6, 2002, at 11:58 AM, David T-G wrote: Hi, all -- I have a php script which writes comments out to a file in the format field@@comment field@@comment

RE: [PHP] replacing \n with br

2002-09-06 Thread Brian V Bonini
I'm sorry, I missed the first part of this thread so am only going by its subject line mostly... But, I assume you are all aware of the nl2br function and there's a special reason it does not apply here but I thought I'd mention it any way... Just in case... :) -B -- PHP General Mailing List

[PHP] (SOLVED) Re: [PHP] replacing \n with br

2002-09-06 Thread David T-G
Rob, et al -- ...and then Robert Cummings said... % % David T-G wrote: % % ...and then Robert Cummings said... % % ... % % $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

Re: [PHP] replacing \n with br

2002-09-06 Thread David T-G
Brent, et al -- ...and then Brent Baisley said... % % Why not just use the nl2br() function? It's a lot easier that using any Because it doesn't do what I need. From the Fine Manual: nl2br -- Inserts HTML line breaks before all newlines in a string string nl2br ( string string)

Re: [PHP] replacing \n with br

2002-09-06 Thread David T-G
Brian -- ...and then Brian V Bonini said... % % I'm sorry, I missed the first part of this thread so am only going by its % subject line mostly... But, I assume you are all aware of the nl2br function Well, only sorta; I said replace in there, you may notice. % and there's a special reason

Re: [PHP] replacing \n with br

2002-09-06 Thread Brent Baisley
Sorry. Since you were looking to use br, I thought you were creating HTML content. But then, line feeds are ignored in HTML so then you wouldn't have a problem with them. I should have thought of that. How are you reading the file? The key being that you said you read it line by line. Once

Re: [PHP] replacing \n with br

2002-09-06 Thread David T-G
Brent -- ...and then Brent Baisley said... % % Sorry. Since you were looking to use br, I thought you were creating % HTML content. But then, line feeds are ignored in HTML so then you Well, yes and no. % wouldn't have a problem with them. I should have thought of that. Well, yes and no

Re: [PHP] replacing \n with br

2002-09-06 Thread Robert Cummings
David T-G wrote: Brent -- The data file format is field@@data field@@data ... and a real example is comment@@this is a comment latdir@@N londir@@W latdec@@36 londec@@89 ... and my code [now, after mods,] looks like ... if (