note 8377 deleted from function.fgets by sniper
| From: | sniper@php.net | Date: | Sat, 08 Feb 2003 20:08:11 +0000 |
| Subject: | note 8377 deleted from function.fgets by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43654@lists.php.net to get a copy of this message | ||
A common mistake is given in the previous example. That is, if the string you're searching for
occurs over a boundary (in this case, of 4k). For example, if the word "hello" were found
starting at the 8th character and I read 10 characters, "hello" would not be found. If I
read the next 10 characters, "hello" would again not be found (although "llo"
would be).
One solution is to always increment your buffer by BUFFER_SIZE - (SEARCH_STR_LEN-1). That will make
sure your search string shows up.
$i = 0;
$search = "hello";
(loop while not eof ...)
$i += 4096 - (strlen($search) - 1);