how to reformat text information from webform add return enter between lines

RegisterLogin
how to reformat text information from webform add return enter between lines
Post Description: how to reformat text information from webform add return enter between lines
Tags: how, to, reformat, text, information, from, webform, add, return, enter, between, lines
This Post Was Posted On Feb 29, 2008 By web hosting #1284
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


Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2012 Webune Forums - Mon Dec 17, 2012 9:57 pm
Powered by: Webune Forums V3