At 22:15 22.02.2003, Al said: --------------------[snip]-------------------- >I spent hours trying every User Notes in the PHP Manual for this simple >operation. e.g., > >$txt= preg_replace("\r\n", "<br>", $words); > >and this version > $txt = preg_replace("/(\015\012)|(\015)|(\012)/","<br />", $txt); > >I can substitute other characters and dec equivalents and the >substations just won't work for \r\n [or just \r or just \n] or "\015" >or "\15". > >And, I've tried using "10" and "010" and "13" and "013". > >And nl2br doesn't work either. --------------------[snip]--------------------
nl2br() doesn't work? Then you don't have newline characters in your text. Maybe this is some Mac issue - I've heard that it might be possible that sometimes lines come separated by CR only. Try this: $asrch = array("/\n\r/s", "/\r\n/s", "/\n/s", "/\r/s", "/<br \/>/s"); $arrpl = array("<br />", "<br />", "<br />", "<br />", "<br />\n); $result = preg_replace($asrch, $arepl, $text); Should catch all possible variations, and finally substitute your "<br />" with a "<br />" followed by a newline character, to beautify the output. Note the "s" modifier that tells the regex parser to handle $text as a single line. If this is missing it will not find newline characters... -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php