At 6/5/2007 10:50 PM, Jim Lucas wrote:
Windows uses \r\n newlines; *nix uses \n; Mac uses \r.
...
PHP Code:
$txt = preg_replace('/\r\n|\r/', "\n", $txt);


Another way to write that PCRE pattern is /\r\n?/ (one carriage return followed by zero or one linefeed).

I recall also running into \n\r although I can't recall which system uses it.

As an alternative to PCRE, we can pass arrays to PHP's replace functions, e.g.:

        $txt = str_replace(array("\r\n", "\n\r", "\r"), "\n", $txt);

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to