Page 1 of 1

How to write an end line to a file?

Posted: Fri Jan 31, 2003 3:26 pm
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...

Posted: Fri Jan 31, 2003 3:34 pm
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";
?>

ok

Posted: Fri Jan 31, 2003 3:38 pm
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);

Re: ok

Posted: Fri Jan 31, 2003 3:51 pm
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");
?>