Blowtar
Blowtar

Reputation: 996

How to I add a line break after each full stop in php, when pulling text from the database?

I have text within one of my tables which is a long description, but the text is all clumped together. I need a way for PHP to find each full stop and add a line break after it, so I can treat the description as a list.

A better solution would be to add an

  • tag at the start of each sentence, and have each sentence finish with a
  • so I can actually add bullet points.

    Thanks.

    Upvotes: 0

    Views: 3600

    Answers (1)

    Eric J.
    Eric J.

    Reputation: 150138

    You can use the str_replace function to replace each occurrance of a full stop with a full stop plus a line break. If you are rendering HTML, a line break is probably the <br/> tag.

    Upvotes: 2

    Related Questions