Re: Line breaks in form

From: Date: Mon, 29 Nov 2004 17:41:30 +0000
Subject: Re: Line breaks in form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203076@lists.php.net to get a copy of this message
Chris Farrugia wrote:
Greetings, On one of my forms to send email, I have multiple line breaks with different paragraphs. I looked up the nl2br function and that looks like an option, but I would ideally like to wrap these paragraphs inside <p></p> tags. Is there a way to do this easily? Any advice would be greatly appreciated.
I'm sure somebody will have a 'cleaner' way, but... $text = preg_split ( "/\n/", $inputText ); for ( $i = 0; $i < sizeof ( $text ); $i++ ) { if ( $text[$i] != "" ) { $text[$i] = "<p>" . $text[$i] . "</p>"; } } -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#203076) next »