the next part is myfunction, which opens the file and places the pointer at the end. He then checks each $char
character in reverse order until it finds a newline or carriage return character.
The problem is that it does not recognize these characters.
The function is as follows:
while(count($results) < $limit && fseek($this->_pointer, $offset, SEEK_END) >= 0) { $char = fgetc($this->_pointer); if($char == '\n' || $char == '\r'){ print("YAY"); $offset --; $data = $this->explodeData(fgets($this->_pointer, 1024)); array_push($results, $this->formatRow($data)); } $offset--; }
It never copes with print("YAY")
, however, it successfully tests each character. The file he is reading definitely has newline characters in it. (The file was created by another function and "\n"
was inserted into it, it displays inside it and successfully displays in my IDE as alternating lines).
Does anyone know why he cannot recognize these newlines?
George Reith
source share