Page 1 of 1

Not sure if this is PHP or HTML

Posted: Wed Apr 22, 2009 12:10 pm
by sleepydad
I have created a page using a textarea to capture text that is sent via php (using 'POST') to a flat/.txt file which is then outputted by Flash. Got all that? : )

The problem that I'm running into is that the text is being relayed to the .txt file as double line spaced and thus displaying that way in the final Flash output.

My php reads

Code: Select all

 
$evaluate=$_POST['evaluate'];
 
if($evaluate=="blogUpdate") {
 $newFile=stripslashes($_POST['newBlog']);
 $newFile = str_replace("\r", "\n", $newFile);
 $open = fopen("blog.txt","w+");
 $text="blog=".$newFile;
 fwrite($open, $text);
 fclose($open);
 }
 
As mentioned previously, the HTML is a standard textarea, so I didn't feel the need to post that code here. The text file was created in BBEdit and saved as blog.txt.

Thanks in advance for suggestions -
sleepydad

Re: Not sure if this is PHP or HTML

Posted: Wed Apr 22, 2009 1:22 pm
by liljester
this may be your problem:

Code: Select all

$newFile = str_replace("\r", "\n", $newFile);
windows typically uses "\r\n" for a new line, so you may be changing "\r\n" to "\n\n" giving you the extra newline.

if you want to strip the carriage returns "\r" try this:

Code: Select all

$newFile = str_replace("\r", "", $newFile);