note 81525 deleted from function.fgets by nlopess
| From: | nlopess@php.net | Date: | Sun, 02 Mar 2008 22:18:24 +0000 |
| Subject: | note 81525 deleted from function.fgets by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-136675@lists.php.net to get a copy of this message | ||
Note Submitter: hamiltont at gmail dot com
----
Oops - i need to clarify on my previous post, someone already told me they didnt get it.
If you use this technique (multiple fgets) you need to realize this will move the file pointer
accordingly. If you are not sure your data is structured all perfectly, here is how you be SURE you
get everything
1)you script will be a little slower, but
2) you will not miss a lot of items due to one faulty entry
while (!feof($h_read))
{
$data = fgets($h_read);
$first_line = ftell($h_read) . "<br>";
$data .= fgets($h_read) . fgets($h_read) . fgets($h_read) . fgets($h_read) . fgets($h_read)
. fgets($h_read) . fgets($h_read) . fgets($h_read);
$last_line = ftell($h_read) . "<br><hr>";
fseek($h_read,-($last_line - $first_line), SEEK_CUR);
blah blah
basically you are making the file pointer move one line at a time, but every time it moves one line
down it pulls in about ten to test them. Then the pointer moves down one more, grabs ten, ect
as i said, slower but safer