Jump to content

Writing to file, new line character \n doesn't work


HughbertD

Recommended Posts

Hi all,

 

I am writing some data to a file (well appending)

 

I am using \n for a new line return, but all I get is a small square, and all the data is on one line

 

$file="export_$time";
$handle=fopen($file,'a');
$data="$start2 TO $end2\n";
fwrite($handle, $data);
fclose($handle);

 

Thanks for any help you can give.

Link to comment
Share on other sites

If you open it in word or some rich text editor then save it, it will work.

 

It's just the way notepad is.

 

or a less im missing somthing on how to get past it...

 

Give \n\r a try but im sure it does the same.

 

Rgards

Liam

Link to comment
Share on other sites

\r\n worked!

 

Thanks!

 

\n = windows systems

\r = unix

 

when you use both the version of OS you run ignores the other usually

 

Are you sure? From what I have found through experience, *nix is \n while windows is \r\n

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.