Tips: Textarea accepts New line ( \n )

The <textarea> tag defines a multi-line text input control.
A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
The size of a textarea can be specified by the cols and rows attributes, or even better; through CSS' height and width properties.

<textarea name="products" cols="23" rows="3"></textarea>


 Test First Line

New Line

 $products = str_replace("\n", "<br>", $_POST['products']);

   Parameter :  str_replace("search", "replace",  $content);

note: str_replaceReplace all occurrences of the search string with the replacement string

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

2 comments: on "Tips: Textarea accepts New line ( \n )"

ist said...

Hi Chi,

There is also another function in PHP called nl2br which can also do what you want to achieve

BTW, I'm also a PHP Developer based in Philippines here's my blog link :)

:) ) ;) ) ;;) :D ;) :p :( ( :) :( :X =(( :-o :-/ :-* :| 8-} :) ] ~x( :-t b-( :-L x( =))
Post a Comment