![]() |
Echoing Text File Rows into Array Display...
Hi all ^^
Right now i can display each row of my text file using echo... I have my rows divided up by ||... for example: me||10-02-07||information on php you||1-12-07||some more info... I would like to make it look like: Who posted: ME Date: 10-02-07 Comment: information on php Right now I am using a foreach loop to grab the data. PHP Code:
Thanks!:-D |
I see some other posts with similar thoughts... but not quite what i am looking for...
|
Is there a particular reason why you want the file format to be in that structure? It's not an ideal structure to read :-) For example, to read a structure like that you'd have to read each 3 line block. This means that if you decided to add a 4th line to future blocks, the script would break quite badly.
If you really want that format is it possible that your app could use XML instead? That would make it a lot easier to read/write to and save a lot of work if you decide to change the format in the future :-) Alan |
How about:
PHP Code:
while .... |
For right now I would. I know XML is the better choice, but I don't have the grasp yet on it to do this.
I have it working: PHP Code:
I have tried: if(!empty($file)){die} But it doesn't work. I would like it not to loop, unless there is at least 1 post. |
I know that you want to use text files for storing your data at the moment, but for future use and for others looking to do similar, I'd like to suggest using SQLite instead - TalkPHP - Introduction to SQLite :-)
Alan |
Thanks for the post. Is that system more streamlined that what I have?
Quote:
|
Quote:
*!* |
Just an addition, you can check if a file exists using the file_exists() function, and the filesize() function will tell you the file size in bytes.
PHP Code:
|
umm...fscanf?
|
thanks all,
got it working great. |
I guess I do have one more question... Is there a way to read the file backwards in order to post the older posts at the end and the new ones first inside the text file?
|
| All times are GMT. The time now is 09:48 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0