Linto
Linto

Reputation: 1282

Html form values not getting as typed +php

I have a php page

 <table width="i00%" border="0">
     <tr><td>Comments</td>
     <td><label>
       <textarea name="comments"></textarea>
    </label></td></tr</table>

I am typing some values in the comment box like this *

first sentence 
second sentence

but when i try to echo the comment box value as echo $_POST['comments']; it will out put as

first sentence second sentence.

How can i out put it as

first sentence 
second sentence

Upvotes: 0

Views: 86

Answers (2)

BrynJ
BrynJ

Reputation: 8382

You could wrap it in nl2br() - http://php.net/manual/en/function.nl2br.php

Upvotes: 0

ceejayoz
ceejayoz

Reputation: 180023

Run it through nl2br(). Line breaks have no meaning in HTML output.

Upvotes: 4

Related Questions