ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-general
php-general
[PHP] Need help with line breaks in a textarea form
by PHP User other posts by this author
Jul 16 2004 5:48AM messages near this date
Re: [PHP-DEV] Clarification needed | Re: [PHP] Need help with line breaks in a textarea form
Hi,

I have been trying to format the textarea output and have come across some
code that almost does what I need, but I still have one small problem.

Look at the text below that was input into my textarea:

Now is the time for all young men to come to the aid of the party. Now is
the time for all young men to come to the aid of the party.
Testing
Now is the time for all young men to come to the aid of the party. Now is
the time for all young men to come to the aid of the party.
Testing.

When I print this out to my webpage it has a line break before and after the
word Testing. I want it to be a wysiwyg - so in the case above there should
be no extra line breaks. It should look exactly as typed.

The code I tried to change the \n to <BR>  are:

$text2= nl2br ($text); 
or
$text2 str_replace("\n","<br> ",$text);

This is what I have in my form.

<textarea rows=10 cols=51 name="text"> <textarea>

Thanks, any help is appreciated.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
PHP User
John W. Holmes
PHP User
PHP User

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved