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 Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/ Share on other sites More sharing options...
papaface Posted December 17, 2007 Share Posted December 17, 2007 \n\r i think Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/#findComment-417048 Share on other sites More sharing options...
kts Posted December 17, 2007 Share Posted December 17, 2007 I've always used \n Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/#findComment-417052 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); ?> Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/#findComment-417059 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 Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/#findComment-417068 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 Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/#findComment-417069 Share on other sites More sharing options...
graham23s Posted December 17, 2007 Author Share Posted December 17, 2007 done thanks guys Graham Link to comment https://forums.phpfreaks.com/topic/82073-line-break-using-fwrite/#findComment-417077 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.