/    Sign up×
Community /Pin to ProfileBookmark

Saving information in .txt to be retreived later: possible?

OK, I know how to write to a .txt file, and I know how to retreive the contents and modify them to some degree, but I want to be able to parse them for something like information between special characters to be put into a variable.

What I’m thinking is something like.. this’d be the .txt file

[code]
|||example post|||
:::someguy:::
;;;3/27/04;;;
Lorem ipsum blah blah example example woot.[/code]

this’d be the results of the php file..

[code]<html>
<head>
<title>example post</title>
</head>
<h2>Example post</h2>
<pre>Lorem ipsum blah blah example example woot.</pre>
<p>Posted by <i>someguy</i> on 3/27/04</p>[/code]

Can anyone tell me at least where to start? I’m somewhat of a PHP n00b, but if you show me the right functions, and give me a push in the right direction, then I should be able to handle the rest myself with ease.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@Paul_JrMar 28.2004 — I would say this is more suited for a DB. ?

But if you were to use a .txt file, I would say you'd have to insert the contents with some sort of special character separating them. You could probably have another character separating the different posts, and you can explode the whole thing into a multi-dimensional array. I don't really know how'd you do this, as I know very little PHP, but in theory it should work.
Copy linkTweet thisAlerts:
@Ben_RogersauthorMar 28.2004 — I'm going to have each post in a different file, but exploding it... i just thought of something.
Copy linkTweet thisAlerts:
@Paul_JrMar 29.2004 — Incase anyone was interested, I got the .txt file thing to work, but I didn't even have to explode it. ?

Though I still have to work out how to get the posts to appear with the most recent on top, and the apostrophes are automatically escaped for some reason...

It's located [URL=http://pauljunior.no-ip.com/research/php/post-system/]here[/URL].
Copy linkTweet thisAlerts:
@Ben_RogersauthorMar 29.2004 — Yes, but I'm keeping author, title, date of post, and the post itaelf in the same .txt file.
×

Success!

Help @Ben_Rogers spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...