note 81525 added to function.fgets

From: Date: Sun, 02 Mar 2008 20:53:23 +0000
Subject: note 81525 added to function.fgets
Groups: php.notes 
Request: Send a blank email to php-notes+get-136671@lists.php.net to get a copy of this message
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 ---- Server IP: 209.41.74.194 Probable Submitter: 129.59.82.21 ---- Manual Page -- http://www.php.net/manual/en/function.fgets.php Edit -- https://master.php.net/note/edit/81525 Del: integrated -- https://master.php.net/note/delete/81525/integrated Del: useless -- https://master.php.net/note/delete/81525/useless Del: bad code -- https://master.php.net/note/delete/81525/bad+code Del: spam -- https://master.php.net/note/delete/81525/spam Del: non-english -- https://master.php.net/note/delete/81525/non-english Del: in docs -- https://master.php.net/note/delete/81525/in+docs Del: other reasons-- https://master.php.net/note/delete/81525 Reject -- https://master.php.net/note/reject/81525 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136671) next »