Jump to content

[SOLVED] Flat File Databases


Altec

Recommended Posts

I'm writing a very small test script to get familiar with flat file database techniques. In this case I'm using just a text file and plan on using a pipe ( | ) to separate my fields. However, I'm interested in limiting how many rows are stored. For example, if I wanted to limit how many comments are stored, and each subsequent comment made "pushes" the oldest comment out, how would I do this?

 

I should also mention I know the basics of reading and writing to files.

Link to comment
Share on other sites

use \x01 to seperate your fields, you will never get someone to input \x01 and if they do.. just do

 

str_replace("\x01","",$inputText);

 

because I use | alot lol even outside of programming..

 

and the best method I guess.. would be to read out your file.. append your new input text to the array containing all other comments.. get the last 10 elements of the array, then clear the text from the file then put the 10 elements you've gotten back into the file..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.