note 11057 deleted from function.nl2br by aidan

From: Date: Sun, 10 Oct 2004 10:39:58 +0000
Subject: note 11057 deleted from function.nl2br by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78291@lists.php.net to get a copy of this message
Note Submitter: CK1 at wwwtech dot de ---- Hi, in answer to eightraks@linux-foo.com: I think, this should work better: $txt = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$txt); It should work on windows with unix style newlines and mac style newlines, it should work on unix with windows style newlines and mac style newlines and it should work mac with windows style newlines and unix style newlines. Windows style newlines are like this: <CR><LF> -> \r\n -> \015\012 Mac style like this: <CR> -> \r -> \015 Unix style like this: <LF> -> \n -> \012 \012 -> 10 -> \n \015 -> 13 -> \r You shouldn't use \n or \r for replacing, because \n for windows is on unix enviroments \r\n and on mac enviroments \r - so you won't match newlines of foreign systems. greets, CK1

« previous php.notes (#78291) next »