feof problem php3.x
| From: | Infobasic | Date: | Wed, 11 Oct 2000 16:08:31 +0000 |
| Subject: | feof problem php3.x | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19621@lists.php.net to get a copy of this message | ||
Have a feof problem....
As I understand the above php 3.x function I should be able to detect the
end of file to prevent a cycle thru a while loop for ex.
while (!feof($a)){
get the first line from file $a
do this and that
}
I have a list of file names each followed by a \r\n including the last entry
in the list.
Everythings works fine until I get to the last entry...php does not read the
last entry
lastfilename.txt\r\n as the last entry, it tries to go thru the loop one
more time.
I've even tried using a do...while loop, still php tries to read an entry
after the last
filename...there is nothing after the last entry with the \r\n\, I checked
using a hex editor.
Now I have to add a line after the while loop
if (strlen($line) <
{
break;
}
testing to make sure the entry is not empty to
prevent php from trying to cycle thru the loop without a file name. This seems to defeat the
purpose of the feof loop...I mean, an eof should be an eof, right???
I'm not sure what I'm doing wrong, it's a simple while loop using feof
Any help appreciated.....
ken