Jump to content

Writing records to file instead of a DB


ballhogjoni

Recommended Posts

its a pain in the ass but

 

www.php.net/fopen

www.php.net/fwrite

 

You have to have a "split" to the line and put each record on a new line.

 

The split needs to be something that won't be in the text so something like :||:  would be your splitter:

 

jack:||:John Barker:||:May 22nd 207:||:Jack, Likes having the moon!

 

Just be wary that if someone uses the :||: in the text it could break it, so you may want to replace that with something before you combine them together.

Good luck keeping them organised, but here's how to write.

 

//  Open to stream $fp
$fp=fopen("file.txt", "r+b");
//  Take out the b in "r+b" if you're not hosting on windoze
//  File needs to exist
$string="What to write to file";
fwrite($fp, $string);
//  (stream, content)
//  I believe that that appends.  If you want it to not append, I recommend deleting it, then re-creating it, with unlink, touch.

 

Hope this helps.

Archived

This topic is now archived and is closed to further replies.

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