On Sat, 12 Aug 2006 16:36:36 -0500, Richard Lynch wrote: > On Fri, August 11, 2006 3:11 am, Ivo F.A.C. Fokkema wrote: >> Well, if it's true that some browsers on some platforms ignore the W3C >> standard, I guess we could use: > > Or perhaps these browsers pre-date W3C standards. :-) Sure, but in newer versions, they might update their code to follow the standards after all... wouldn't they? >> $datelist = >> str_replace(array("\r\n","\n","\r"),'<BR>',$_POST['datelist']); > > Two problems here. > > This assumes a specific undocumented ordering to the replacement in > processing the array argument. If, for some insane reason, the PHP > implementation of str_replace chooses to process that input array in > reverse order, you would end up with double <BR> for "\r\n" input. This > is incredibly unlikely, but it's NOT (yet) documented that the arrays > are processed in order. True; and I haven't tested the code either, to be honest. I found the basic implementation on a forum somewhere and adapted it to the threadstarter's need. I might try and see if I could submit a documentation bug on this. I think it's a useful feature and you're right to claim that since it's not documented, one should not rely on it. > The next problem is that replacing newline (in any form) with <BR> on > the INPUT phase of your program is just a Bad Idea. :-) > > (...) > > Because someday you may want to output that same data to RSS, XML, or > XYZ, in which case <BR> is NOT what you want for your newlines. Hey, totally agree here, BUT, the threadstarter doesn't mention it being put in a database. Actually, he just requests it to be written on a new line in the output. I just provided him a way of doing this. I always store the input directly in the database (quoted, then, of course) and replace \r\n with <BR> when needed (display on screen). I've had no problems by strictly using \r\n yet. But as I have an open source project, I assume someone will (be telling me||submit a bug) if they have problems. In that case, I will implement a non-W3C compliant hack ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php