Closed Thread Icon

Preserved Topic: auto inserting P tags in PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=20952" title="Pages that link to Preserved Topic: auto inserting P tags in PHP (Page 1 of 1)" rel="nofollow" >Preserved Topic: auto inserting P tags in PHP <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-18-2001 18:23

I have a form that lets me insert data into a MySQL table. However, I have one field that is an article body. I toss all the text into the form field, with carriage returns for the paragraphs. When it gets enterered into the database, and, subsequently displayed in HTML, I don't have any spaces between the paragraphs (no big surprise). Is there a way (in PHP) to automatically change carriage returns to <p> tags or something similar?

Obviously, I could just manually put the <p> tags in the text when I submit it to the database, but I want to avoid this, since some people who will use this won't be HTML literate.

Would Substr_replace() be a good candidate for this?

Thanks!



[This message has been edited by Pugzly (edited 07-18-2001).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-18-2001 18:29

nl2br() is your friend.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-18-2001 18:52

Yes it is!

Thanks!

« BackwardsOnwards »

Show Forum Drop Down Menu