Depending on what system you're using, the EOL (end of line) character
is going to be different.

On a DOS/Windows system, you want to use "\r\n".

I can't remember off the top of my head now, but some systems use just
"\r" and some use just "\n"..   DOS/Windows systems use both, and I
believe they need to be in \r\n order, not \n\r.

If you're not sure if you're saving them properly, load the text file
into Notepad and you'll see a weird square character show up if the line
break (EOL) character(s) is wrong.

Maybe I'm lazy or uneducated, but I like to just use file() when I'm
reading a text file.  It loads everything into an array that has the
line number and then the entire line, stripping off the \r\n's for you.

Hope this helps a little!

-TG

> -----Original Message-----
> From: tony [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, January 28, 2004 1:53 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] working with files
> 
> 
> hi,
> 
> i have problem with writing a reading to file
> i want to write emails in files. like this
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> etc......
> 
> this is how I write to the file
> 
> $handle = fopen($filename, "a");
> fwrite($handle,"$email\n",128);
> fclose($handle);
> 
> 
> ok it writes everything just fine but now i want to read the 
> file line by
> line and print line by line.
> this is how i do it.
> 
> <?php
>     $handle = fopen ($filename, "r");
> 
>     do {
>         $data = fread($handle, 128);
>         if (strlen($data) == 0) {
>             break;
>         }
>         print ("$data<br>");
>     } while (true);
>     fclose($handle);
> ?>
> 
> 
> 
> the problem i get then is everything is printed in one line.
> 
> 
> 
> any help is appreciated.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to