PHP - how to read big remote files efficiently and use buffer in loop

后端 未结 3 1884
礼貌的吻别
礼貌的吻别 2021-01-21 04:53

i would like to understand how to use the buffer of a read file.

Assuming we have a big file with a list of emails line by line ( delimiter is a classic \\n

3条回答
  •  攒了一身酷
    2021-01-21 05:22

    Like already suggested in my closevotes to your question (hence CW):

    You can use SplFileObject which implements Iterator to iterate over a file line by line to save memory. See my answers to

    • Least memory intensive way to read a file in PHP and
    • How to save memory when reading a file in Php?

    for examples.

提交回复
热议问题