php - Line breaks not going through -
alright site allowing users have description of or whatever like, when attempt make breaks using [enterkey] <textarea>
looks this:
hello, john smith. phone#: (123)456-7890 enjoy web-browsing.
when return page looks same (it puts current description in edit box). want. in php database , still looks same. again want. on profile page looks this
hello, john smith. phone#: (123)456-7890 enjoy web-browsing.
it contained inside div these style tags , so
<div style="width: 250px; min-height: 50px; margin: auto; font-weight: normal; text-align: center; padding: 2px; margin-bottom: 5px;"> <?php echo $description; ?> </div>
im curious why appreciated :d.
add white-space:pre-line
<div>
or, use:
<?= nl2br($description); ?>
remember html needs <br />
line breaks, not \n
or \r\n
(like <textarea>
collecting). can either tell html pay attention new lines using white-space
, or force <br />
using nl2br
.
Comments
Post a Comment