How to write an end line to a file?

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
slipstream
Forum Commoner
Posts: 86
Joined: Fri Apr 19, 2002 8:53 am
Location: Canada

How to write an end line to a file?

Post by slipstream »

How do I add an end line so that my next entry goes on the next line?

fwrite($file, $entry);

I need to add the end line after $entry...
User avatar
puckeye
Forum Contributor
Posts: 105
Joined: Fri Dec 06, 2002 7:26 pm
Location: Joliette, QC, CA
Contact:

Post by puckeye »

Use the \n (that's blackslash n) to create a newline.

EDIT: Inside your string I mean, so with the string you have in the other thread you'd have :

Code: Select all

<?php
$work_str = $name."|".$hours."|".$date."|".$comments."\n";
?>
slipstream
Forum Commoner
Posts: 86
Joined: Fri Apr 19, 2002 8:53 am
Location: Canada

ok

Post by slipstream »

but how can I concatonate that to the end of my entry, I tried this but it doesn't work:

fwrite($file, $entry\n);
User avatar
puckeye
Forum Contributor
Posts: 105
Joined: Fri Dec 06, 2002 7:26 pm
Location: Joliette, QC, CA
Contact:

Re: ok

Post by puckeye »

slipstream wrote:but how can I concatonate that to the end of my entry, I tried this but it doesn't work:

fwrite($file, $entry\n);
Instead use:

Code: Select all

<?php
fwrite($file, $entry."\n");
?>
Post Reply