fgets and feof behaving unexpectedly
Posted: Mon Oct 30, 2006 6:21 am
i have this in a file that im parsing
now when i parse it with the following function......
i get the following delimiters being parsed
......missing out the first line, does anyone have any idea as to why its doing this, i was reading on the PHP manual that there were various problems with feof and that it was an unreliable function.......
Code: Select all
[ID] FS1024583248, 170128, 24/10/2006 04:02:02
[T] 07 43212991
[M]
[E] trentxxxx@hotmail.com
[A] Mr Trent Hatton, 27 High St, , Millaa Millaa, QLD, 4886, Australia
[C] Yes
[R] http://www.redsquareclothing.com/
[I] 72156,55DSL Classic Logo Tee,£24.9899997711182,Med,1,3
[D] 15.50
[END]Code: Select all
function readFileByLine ($filePath) {
$fp = fopen($filePath, "r");
$current_line = fgets($fp);
while (!feof($fp)) {
// process current line
$this->currentLineContent = fgets($fp);
$this->LineDelimiter = $this->getDelimiter ($this->currentLineContent);
$this->sendToAction ($this->LineDelimiter, $this->currentLineContent);
}
fclose($fp);
}Code: Select all
Delimeter = [T]
Delimeter = [M]
Delimeter = [E]
Delimeter = [A]
Delimeter = [C]
Delimeter = [I]
Delimeter = [D]