Question about Julie Meloni tutorial
| From: | Richard M. Pavonarius | Date: | Fri, 07 Jul 2000 13:06:45 +0000 |
| Subject: | Question about Julie Meloni tutorial | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5368@lists.php.net to get a copy of this message | ||
I'm working on the Hotwired "Authenticate and Track Users with PHP" tutorial here:
http://hotwired.lycos.com/webmonkey/00/05/index2a_page3.html?tw=programming
I have a file with user:passwd pairs in it like this:
user:pass
user:pass
user:pass
Three lines only. There definitely isn't a trailing \n at the end. I'm absolutely sure, after checking 100 times.
When I do this:
$filename = "bla/bla/bla/accounts.txt";
$fp = fopen($filename, "r");
$file_contents = fread($fp, filesize($filename));
fclose($fp);
$line = explode("\n", $file_contents);
echo sizeof($line);
...I get 4 instead of 3. $line[3] is empty but it's there. Where is it coming from? Why do I have to use (sizeof($line)-1) to get the right count?
I using BBEdit on MacOS, saving as UNIX text. But the same thing happens if I create accounts.txt with vim or gedit on the Linux server.
If I replace the file reading stuff with $file_contents="user:pass
user:pass
user:pass";
I don't have the problem.
Thanks,
Rich
------------------------------------------------------------------
Richard M. Pavonarius, Global Commons, Inc., Tokyo