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 2:40 am, Reinhart Viane wrote:
> Actually, I know that it's browser/OS dependent, cuz I had a bunch of
> Mac users who sent only \r all the time.
>
> This may be true only of OS 9, and you may not care about them
> anymore, but there it is.
>
> I also would not be so quick to claim that Linux sends \r\n -- It
> could be dependent on the browser, the OS version, the OS distro, some
> OS settings, ...
>
> Better safe than sorry, and I *know* I ran into this with some Mac
> users.
>
> Plus I hate trying to edit the text chunks in vi with those icky \r
> thingies that turn into ^M :-)
>
> What would you suggest to use then?

I would suggest using the code I posted that started this
sub-thread... :-)

//The order of operations is crucual here:
$string = str_replace("\r\n", "\n", $string);
$string = str_replace("\r", "\n", $string);

You could use arrays for str_replace, and reduce the function calls,
but that relies on the ORDER in which the array/substitutions are
processed.

While I can't imagine the array version of str_replace doing them in
reverse order, it is not currently a documented behaviour, so I
personally would just take the penalty of 2 function calls, unless
it's a proven performance problem (which seems unlikely).

YMMV

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