End of line-new line

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have what I thought was a simple task.  I have a file with an orderd list  
in it that I use in a readfile to generate an html page.  When I want to  
insert a new entry into that list, it should be in the proper place.  My  
procedure is to create an array using file('filename').  I then search in  
that list for the proper placement, writing each line to a target file with  
an fwrite command.  I write the new line and then I write the rest of the  
array.  Simple, yes?

Well, all the lines that I generated with the file command write back  
perfectly.  I cannot seem to get the new entry to generate a line  
feed-carriage return.  This is on a Windows system.  I have tried "\n" and  
have "\r\n" and even nothing at all.  No success.  I have temporarily done a  
work-around by having the first line of the original file be blank and  
appending $lines[0] to the new entry where $lines is the array I generated.

Any ideas?  I would like to solve this the correct way.

Note:  I added the formatting as follows
fwrite($handle, "The new entry information\r\n");


Re: End of line-new line

Sheldon Glickler wrote:

Quoted text here. Click to load it

show some code please.

Erwin Moller

Re: End of line-new line

"Erwin Moller"  

Quoted text here. Click to load it
The solution was to double quote the \n and  \r.  IOW  have

$to_be_written= $the_added_line . "\r\n" ;
fwrite($handle_for_open_file,  $to_be_written);l.

I found this buried dedep inside the fwrite documentation.  I know, Iknow.  

www.php.net is great.


Site Timeline