How do I open a file from line X to line Y in PHP?

后端 未结 7 1261
情书的邮戳
情书的邮戳 2020-11-29 13:09

The closest I\'ve seen in the PHP docs, is to fread() a given length, but that doesnt specify which line to start from. Any other suggestions?

相关标签:
7条回答
  • 2020-11-29 14:14

    I was afraid of that... I guess it's plan B then :S

    For each AJAX request I'm going to:

    1. Read into a string the number of lines I'm going to return to the client.
    2. Copy the rest of the file into a temp file.
    3. Return string to the client.

    It's lame, and it will probably be pretty slow with 10,000+ lines files, but I guess it's better than reading the same over and over again, at least the temp file is getting shorter with every request... No?

    0 讨论(0)
提交回复
热议问题