I'm getting text from my MySQL database which is broken into lines (paragraphs). It's stored in the variable $post_data['content']. How do I make it print out with the line breaks?
The code I'm currently using:
$post_data['content'] = explode("\n", $post_data['content']);
$post = "<p>" . implode("</p><p>", array_values($post_data['content'])) . "</p>";
This doesn't work to the extent I want it to.
If I have text like this in the database:
line 1 paragraph 1,
line 2 paragraph 1.
line 3 paragraph 2,
line 4 paragraph 2,
line 5 paragraph 2.
The code would display like this (which I don't want):
<p>line 1 paragraph 1,</p>
<p>line 2 paragraph 1.</p>
<p>line 3 paragraph 2,</p>
<p>line 4 paragraph 2,</p>
<p>line 5 paragraph 2.</p>
I want it to group the paragraphs together if there's no white-space between lines (just one line break). Perhaps something with the array after the explode?
nl2br()?