hi guys,
Need your hlep. I'm using a simple code to read a text file (line by line) using fgets() and feof(). There are only 5 lines in the text file however, the feof reports that there are 6 lines (which is not true). Can anyone help me in this? The following is how the code looks like this :
<?php
// Associate the file to the filename variable
$filename = 'bkup03.log';
// Open the file and read line by line
$fp = fopen("$filename", "r") or die("Couldn't open $filename");
$x = 1;
while (!feof($fp)) {
echo "Line No. : $x\n";
$x = $x + 1;
$line = fgets($fp);
}
fclose($fp);
?>
I've put in a counter to "debug" and noticed that it even runs beyond the 5th line and the counter keeps on increasing. Something wrong with the loop.