reading a block of lines in a file using php

后端 未结 5 1501
旧时难觅i
旧时难觅i 2020-12-20 03:16

Considering i have a 100GB txt file containing millions of lines of text. How could i read this text file by block of lines using PHP?

i can\'t use file_get_

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-20 03:49

    I would recommend implementing the reading of a single line within a function, hiding the implementation details of that specific step from the rest of your code - the processing function must not care how the line was retrieved. You can then implement your first version using fgets() and then try other methods if you notice that it is too slow. It could very well be that the initial implementation is too slow, but the point is: you won't know until you've benchmarked.

提交回复
热议问题