Jump to content

Zett

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zett's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. That idea would work for a news system or something similar to that. The problem is that it's a guestbook, sometimes people post a lot of messages like "Nice site", "Hi" and so on. So, a file for each post would be too much. Ok, I found a solution. Actually, it's not a solution, it's a workaround. I'm going to use txtSQL which is a pretty neat thing. It's somewhat a flat-file version of mysql. But the problem of reading the file in reverse order is present and I will trying to find a way to do it. I really want to find the answer because this question arose a while ago but I never really had time to look into this problem.
  2. I've tried that and it works well. However, the reason I'm looking for something else is that file() will not be a good option when dealing with large files. I'm working on a guestbook where latest entries are stored at the end of the file. And, of course, latest entries are displayed first. Let's say I have 100 or 200 entries stored in the file, and I only need the last 10. It would be a waste of time and space to copy the whole file into an array and then choose 10 entries. What if there were 1000 or 10 000 entries in the file (I hope you get the idea). I can also simply scan throw the whole file without copying anything until I come to the 10th last entry. From that point to the end I get my 10 latest entries. It would be great if there was a function like fgetrs (like strpos/strrpos) for reading file backwards.
  3. Hi. I'm wondering if any of you could help me with the algorithm/code for reading a text file [u]line-by-line[/u] in a [u]reverse[/u] order. The delimiter is a newline character "\n". Basically I just want to put the pointer to the end of the file and then read it in a reverse (bottom-up) order. Thanks in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.