RE: break up variable and put each element in an array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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. :-)

> $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.

The next problem is that replacing newline (in any form) with <BR> on
the INPUT phase of your program is just a Bad Idea. :-)

The INPUT data should be kept sacrosanct and the OS-dependent newlines
should be converted to newlines.

If the data is output later to a browser, nl2br() should be used.

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.

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux