Re: text formatting in php?

From: Date: Thu, 17 Apr 2003 09:39:46 +0000
Subject: Re: text formatting in php?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144255@lists.php.net to get a copy of this message
Hi Mike, Why not use the wordwrap($string, 72) PHP function? Usage: string wordwrap ( string str [, int width [, string break [, int cut]]] ) Regards, Peter "Pod" Pistorius > 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

« previous php.general (#144255) next »