retaining format of textarea
Moderator: General Moderators
-
Grahamhart
- Forum Commoner
- Posts: 27
- Joined: Wed Jun 11, 2008 6:05 am
retaining format of textarea
Tryed googling this but didnt get far was wondering if any1 had any ideas.
Is it possible to change all occurances of \r\n in a file to there html equivilants as you include the file?
Is it possible to change all occurances of \r\n in a file to there html equivilants as you include the file?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: retaining format of textarea
You could use an editor such as FCK editor or try encoding the textarea content i.e. urlencode().
-
Grahamhart
- Forum Commoner
- Posts: 27
- Joined: Wed Jun 11, 2008 6:05 am
Re: retaining format of textarea
I just tryed TinyMCE to write the include file but again it didnt retain, just put in \r\n
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: retaining format of textarea
Can you show your code?
-
Grahamhart
- Forum Commoner
- Posts: 27
- Joined: Wed Jun 11, 2008 6:05 am
Re: retaining format of textarea
ok code to take info from textarea and make it an include is as follows, also tryed doing this as .php
$str = "$comments";
file_put_contents("includes/'$thread'.inc", $str);
This include is then called on another page.
$str = "$comments";
file_put_contents("includes/'$thread'.inc", $str);
This include is then called on another page.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: retaining format of textarea
Remover the double quotes from the following line:
Code: Select all
$str = "$comments";
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: retaining format of textarea
str_replace should work 
-
Grahamhart
- Forum Commoner
- Posts: 27
- Joined: Wed Jun 11, 2008 6:05 am
Re: retaining format of textarea
hmm str_replace() doesnt seem to wnat to work for me did this.
$order = array("\r\n", "\n", "\r");
$replace = "<br />";
$str = str_replace($order, $replace, $comments);
yet the \r\n's are still there
$order = array("\r\n", "\n", "\r");
$replace = "<br />";
$str = str_replace($order, $replace, $comments);
yet the \r\n's are still there
-
Grahamhart
- Forum Commoner
- Posts: 27
- Joined: Wed Jun 11, 2008 6:05 am
Re: retaining format of textarea
hmm found the problem, i was striping slashes out. which i dont need to do as this doesnt goto an sql database.
thanks
thanks