How To Reformat Text Information From Webform Add Return Enter Between Lines

Mobile
feeds
Welcome Login | Register

How To Reformat Text Information From Webform Add Return Enter Between Lines
  Forums Index
      » PHP Forums
        » » how to reformat text information from webform add return enter between lines



How To Reformat Text Information From Webform Add Return Enter Between Lines
Post Description:
Post Tags: how, to, reformat, text, information, from, webform, add, return, enter, between, lines, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 316 Times Since Mon Feb 04, 2008 12:24 pm Posted By hostman with 1 replies
How To Reformat Text Information From Webform Add Return Enter Between Lines
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






Share
URL:
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites



Fourms BBCODE:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums





Comments and replies About How To Reformat Text Information From Webform Add Return Enter Between Lines




:: 1 :: Reply #69604 Reply By George On Sat Sep 06, 2008 9:10 am
this doesn't work either. i tried a simple test:

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.