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.

Link to comment
Share on other sites

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.

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.