- Forums
- PHP
- How To Reformat Text Information From Webform Add Return Enter Between Lines
This Page Contains information about How To Reformat Text Information From Webform Add Return Enter Between Lines By wallpaperama in category PHP with 1 Replies. [1073], Last Updated: Sat May 18, 2024
wallpaperama
Mon Feb 04, 2008
1 Comments
708 Visits
ok, today i had a script. and im not an expert on php, but when i finished my form, i ended up with one whole long line instead as the actual information i input on the form. instead, in my database i saw /r/n so when i displayed the information from my textarea that i entered on my form it came out on one long continuous line.
for example lets say i entered this information on my form textarea:
INPUT
wallpaperama is cool
this is the second line
and this is the fourth line
so when i get the information from my database and i display it on my web page, is shows like this:
OUTPUT
wallpaperama is cool this is the second line and this is the fourth line
as you can see, its a long continous line and that's not how it was entered, i want to show it as the user entered it. so how do you do it.. simple
i created a function or a class you can use to format the text so that it will show exactly as it was entered into the form
PHP FUCNTION:
function form_txt($text){
$text = str_replace("\n", '<br>',$text);
return $text;
}
lets say my datbase field is called
content
so using the function above i can clean up by using this code:
CODE:
echo form_txt($content);
so once i do that it will display my content as this:
wallpaperama is cool
this is the second line
and this is the fourth line
line 1
line 2
$text = str_replace("n", ...);
the above function simply removed the "n" from the word line.
once again it seems solutions are offered that have not been tested. and no, i don't have a solution. i came to this ste looking for one.
https://www.wallpaperama.com/forums/how-to-reformat-text-information-from-webform-add-return-enter-between-lines-t5701.html