Not sure if this is PHP or HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Not sure if this is PHP or HTML

Post 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
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Not sure if this is PHP or HTML

Post 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);
Post Reply