Yes, true. I was in a hurry when I replied earlier. Here's a function I built for reformatting richtext data from textareas:
function rich_text_format($text_field)
{
/*So, we've been passed a bunch of text, full of newlines, and stuff. There's a good chance
that there are great long reams of text, among all this, that run and run. These will simply
output on one line unless we do something to impose some sort of wrapping to them. So let's
impose some word-wrapping, first of all. We use newlines, rather than <br />s at this stage,
since all newlines will get turned into <br />'s, later on, by preg_replace.*/
$text_field = wordwrap($text_field, 75, "\n");
/*Next, let's encode any special characters such as & and so on. We specify that we want
single quotes encoding, too*/
$text_field = htmlspecialchars($text_field, ENT_QUOTES);
/*Now, we build an array of control characters and other stuff we want reformatting...*/
$patterns = array("/ /", "/\n/", "/\t/");
/*...and an array of what we want them to be replaced with.*/
$replacements = array(" ", "<br />", " ");
/*(Add new values to each array as you see fit... Just make sure they correspond with each other and
refer to the manual for guidance (
http://uk2.php.net/manual/en/function.preg-replace.php at time of writing)
Then do the replacement*/
$text_field = preg_replace($patterns, $replacements, $text_field);
//And send this thoroughly 'munged' piece of text back to where it came from...
return $text_field;