Fwrite with new line break problem?

This is a discussion on "Fwrite with new line break problem?" within the PHP Forum section. This forum, and the thread "Fwrite with new line break problem? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 4th, 2008, 15:08
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Fwrite with new line break problem?

Hi People,

If anyone can help me please?

Im trying to write to a txt file and create a new line break from the code i submit.

This is what i'm using as an example:

$myFile = "test.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby\n";
fwrite($fh, $stringData);
$stringData = "Pointy\n";
fwrite($fh, $stringData); fclose($fh);

But when i open the .txt file i end up with:

BobbyPointy

Any suggestions please?

Cheers!

  #2 (permalink)  
Old Feb 4th, 2008, 15:20
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Fwrite with new line break problem?

Are you on a windows system?

If you are, you may need to write

$string = "Bobby\r\n";

As windows handles new lines a bit differently. Try that and see if it works
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
  #3 (permalink)  
Old Feb 4th, 2008, 15:23
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Fwrite with new line break problem?

Brilliant, thanks for the quick response! working!
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[solved] I want to insert a line break minute44 PHP Forum 4 Feb 20th, 2008 12:52
prevent line break after a checkbox pesho318i Web Page Design 7 Feb 6th, 2008 09:34
Blank line problem dartiss Web Page Design 8 Aug 6th, 2007 21:28
Line Break DregondRahl Web Page Design 6 Jun 12th, 2007 15:33
<div> function without the line break Tim356 Web Page Design 10 Sep 27th, 2004 18:39


All times are GMT. The time now is 11:59.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43