Issue
Is there a way to use fgetcsv to open on a particular row?
I have a really big csv and would like to run around 100 lines at a time via ajax. I can easily stop the while loop, but how would I open on a particular line? Or is this impossible?
Solution
There's no simple way to start reading at row 100, but what you can do is read/set the position in the file like this:
$k = <previous position>;
fseek($file, $k);
while(...) {
fgetcsv(...);
...
}
$k = ftell($file); //new position
Now it's just a matter of preserving this position between page calls.
Answered By - Aleks G
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.