php - line breaks in a textarea -


i know when saving textarea can use nl2br() or str_replace change /n br tags etc. im not sure how insert line breaks textarea. cant seem find putting data textarea line breaks.

for example have form users can update fields. user may enter:

foo bar baz 

when saved database saved as:

foo<br />bar<br />baz<br /> 

now when user goes form after page refresh fields automatically populated previous data taking data database.

however textarea shows br tags text instead of adding in line breaks. tried changing br tags /n hoping textarea interpret these line breaks no joy. tried escaping etc.

so questions can done? or more importantly can done using html/php (im using smarty). if isnt possible can done using javascript?

examples appreciated.

thanks reading

don't nl2br when save database. nl2br when you're displaying text in html. can recommend not store html formatting in database (unless you're using rich html editor well, in case silly not to).

a newline \n become newline in textarea.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -