graham23s Posted December 17, 2007 Share Posted December 17, 2007 Hi Guys, how do i do a line break when writing to a text file? i tried: ## referer $ref = $_SERVER['HTTP_REFERER']; $file = "referrer.txt"; $fh = fopen($file, 'w'); $stringtowrite = $ref; fwrite($fh, $stringtowrite); $linebreak = ("<br />----------------------------------------<br />"); fwrite($fh, $linebreak); but this actually prints the br tage. thanks for any help Graham Quote Link to comment Share on other sites More sharing options...
papaface Posted December 17, 2007 Share Posted December 17, 2007 \n\r i think Quote Link to comment Share on other sites More sharing options...
kts Posted December 17, 2007 Share Posted December 17, 2007 I've always used \n Quote Link to comment Share on other sites More sharing options...
graham23s Posted December 17, 2007 Author Share Posted December 17, 2007 ah thanks guys so would this be ok: <?php $ref = $_SERVER['HTTP_REFERER']; $file = "sitestats.txt"; $fh = fopen($file, 'w'); $stringtowrite = $ref; fwrite($fh, $stringtowrite); $linebreak = ("\n"); fwrite($fh, $linebreak); ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 17, 2007 Share Posted December 17, 2007 You can just concatenate the newline character to string you're writing when you write it: <?php <?php $ref = $_SERVER['HTTP_REFERER']; $file = "sitestats.txt"; $fh = fopen($file, 'w'); fwrite($fh,$ref . "\n"); ?> Ken Quote Link to comment Share on other sites More sharing options...
craygo Posted December 17, 2007 Share Posted December 17, 2007 Well if $ref is a whole lot of lines, that won't do much good. You will get everything on one line then a line break at the end. Ray Quote Link to comment Share on other sites More sharing options...
graham23s Posted December 17, 2007 Author Share Posted December 17, 2007 done thanks guys Graham Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.