text formatting in php?
| From: | Mike Jackson | Date: | Thu, 17 Apr 2003 08:20:45 +0000 |
| Subject: | text formatting in php? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-144244@lists.php.net to get a copy of this message | ||
Hi,
I have a form with a textarea. Realizing that "wrap" isn't a standard,
and isn't recognized by all browsers, it really is only useful to the
user while he's filling in the textarea.
I want to email the contents of that textarea, and I want that text to
be line wrapped at 72 characters or sooner so that words are not split
in half.
I could probably do some really ugly hack with exec(fmt), for example,
but can PHP handle this natively?
I want to take this:
$comments = "hello, i'm typing into this textbox and although it appears
to wrap lines when the form gets emailed the lines are not wrapped at
all. I would like to have line wrapping at 72 characters in my email.";
And turn it into this (notice the \r\n sequences in two places):
$comments = "hello, i'm typing into this textbox and although it appears
to wrap lines\r\nwhen the form gets emailed the lines are not wrapped at
all. I would\r\nreally like to have line wrapping at 72 characters in my email.";
And how can I ensure that if the user hits enter twice, to make a new
paragraph, that it is also displayed like that in the email?
Thanks,
Mike