daniel daniel - 9 months ago 51
PHP Question

Read Enter text in php

I have a problem. I have a text that called from database. In database, the text has an enter text. Here is the picture:

enter image description here

But in my website, it has no enter. Here is the picture.

enter image description here

How to read enter in php?

Here is my code:

$ambil = mysql_query("SELECT * FROM blog WHERE id_blog = '" . $id . "' ");
$deskripsi = $tamp->deskripsi;

<p><?php echo $deskripsi; ?></p>

Thank you before :)


Try <p style="white-space: pre">.

You could also replace the newlines in the text with <br> tags.

The latter can be accomplished like this (hat tip to @andrewsi):

<p><?php echo nl2br($deskripsi); ?></p>