Reputation: 2517
I'm sorry if the title sounds confusing but I don't know how to express the problem in one line. Anyway here are the details,
I have a textarea
in which the user input data and then I store the data in my MySQL 5.5 database. The user inputs the data in well formated form i.e. leaving lines using 'enter key'
.
Eg:
text text text text
text text text
text text text text text text
Now when I retrieve the data from the database it is not displayed in the form as it was entered by the user but as follows,
Eg:
text text text text text text text text text text text text text
Is there a way through which I can make the format of the text same as it was entered by the user?
Upvotes: 0
Views: 1747
Reputation: 9635
when you insert the data from textarea new line will be marked as \n
so when you retrieve it and display it in textarea it will display the same as you entered.
But if you want to display it on the html. you will see the plan text without new line because html cannot understand the \n
so replace \n
with html new line tag <br/>
$string = "something \n here";
echo str_replace("\n", "<br/>", $string);
Upvotes: 2