I have a textarea in which the user enters his data. I want to make the PHP code leave lines at places where the user has. Suppose the user enters -
My name is Harry.
I live in LA.
The out put will be
My name is Harry.I live in LA.
Please tell me the function/command we use to solve this problem(I think its a PHP problem)
Thanks in advance.
HTML Code -
<textarea rows='1' cols='50' id='p-text' class='p-textarea' placeholder = 'Write something about yourself here..'> </textarea>
I will output this in a tag, not a textarea.
@zrvan-
Output on var_dump($_GET['t'); is
string(31) "My name is Harry. I live in LA."
nl2br() should solve that if you're echo-ing the string. See: http://php.net/manual/en/function.nl2br.php
Make sure you don't strip the newlines when you add content to the database though.
In fact the output is something like this
My name is Harry.\nI live in LA.
just use http://php.net/manual/de/function.nl2br.php for that :)
/edit: mat was faster :) flag his answer as solution :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With