Jump to content

Ascii text to HTML - Help please


loquela

Recommended Posts

I'm trying to pull text from a database and disply it in HTML.

 

The text in the database contains no html tags so when it is displayed as HTML it is displayed as a continuous string:

 

Database source text:

 

This is the firstparagraph of the text.

This is the second paragraph.

Etc....

 

Text as dislayed in HTML:

 

This is the first paragraph of the text. This is the second paragraph. Etc....

 

What I really want to do is create praragraph blocks in the HTML:

 

This is the firstparagraph of the text.

This is the second paragraph.

Etc....

 

To

 

<p>This is the firstparagraph of the text.</p>

<p>This is the second paragraph.</p>

<p>Etc....</p>

 

Or at the very least replace the ascii line breaks with

<br />

.

 

How is this achieved?

 

 

Link to comment
https://forums.phpfreaks.com/topic/95799-ascii-text-to-html-help-please/
Share on other sites

Many thanks so far.

Could we now go a step further?

 

Instead of having a long string of text with just

<br>

How would it be possible to format the ascii text more semantically:

 

ASCII:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 

Aenean est. Maecenas varius scelerisque ligula. Morbi est nibh, bibendum pulvinar, interdum ac, fringilla non, lacus. 

In hac habitasse platea dictumst.

 

to HTML:

 

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>

<p>Aenean est. Maecenas varius scelerisque ligula. Morbi est nibh, bibendum pulvinar, interdum ac, fringilla non, lacus.</p>

<p>In hac habitasse platea dictumst.</p>

 

Many thanks in advance.

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.