Re: How to jump to line number in large file
| From: | Greg Bowser | Date: | Fri, 04 Apr 2008 23:56:22 +0000 |
| Subject: | Re: How to jump to line number in large file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-272558@lists.php.net to get a copy of this message | ||
fseek($handle, 1, SEEK_CUR); // or fseek($handle, $pos)
$t = fgetc($handle);
This probably won't help you, but given a quick glance, it looks like you're
incrementing the file pointer by 2 positions on each iteration of your while
loop. The fgetc() function returns the character at the current position and
increments the file pointer by 1.
I haven't tried this, but perhaps using strpos would be faster? Use strpos
to seek to find the first "\n", then use the offset parameter to seek to the
second, and so on, until strpos() returns false.
--GREG