ballhogjoni Posted July 6, 2007 Share Posted July 6, 2007 Is there a way to write records and keep them organized to a file instead of a DB? Link to comment https://forums.phpfreaks.com/topic/58701-writing-records-to-file-instead-of-a-db/ Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 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 https://forums.phpfreaks.com/topic/58701-writing-records-to-file-instead-of-a-db/#findComment-291166 Share on other sites More sharing options...
Asday Posted July 6, 2007 Share Posted July 6, 2007 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 https://forums.phpfreaks.com/topic/58701-writing-records-to-file-instead-of-a-db/#findComment-291173 Share on other sites More sharing options...
ballhogjoni Posted July 6, 2007 Author Share Posted July 6, 2007 Thank you, Link to comment https://forums.phpfreaks.com/topic/58701-writing-records-to-file-instead-of-a-db/#findComment-291178 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.