/    Sign up×
Community /Pin to ProfileBookmark

Fetch most recent file to file_get_contents

Hi there. I’ve been fiddling around with the construction of an electronics-related compendium in my spare time for the last couple of weeks. I’ve never really worked with web development before, and my programming knowledge is kind of restricted to C and C++, so being introduced to at least three new languages in the past month has been quite a mouthful, but I’ve managed so far. In my endeavours I’ve stumbled onto a few problems I haven’t quite been able to solve myself or with google, however.

The one that, to me, appears the most tricky is the following:

On the homepage of my site I have three containers. These are suppose to contain some text and an image that I’m to extract from certain html files. The specific files are located in a subfolder called “/articles/”. I’m looking for a function that can fetch the filenames of the most recently, the second most recently and third most recently created files in that directory. I think I’ve figured that the function to extract the elements from the html file would be “file_get_contents(filename)”, but I’m looking for a function that can return the most recent filenames, and pass it to the file_get_contents function.

Is there any chance you guys can at least give me a hint? Or am I heading in a completely wrong direction?

Thanks in advance.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@extinctionauthorJun 20.2011 — So, I think I might've found some way to resolve this, but it led me to an entirely different approach. Instead of fetching the contents from html files, I chose to store all the articles in an SQL database, and just make a simple query (fetching the three most recently created rows) to grab the specific contents.

This approach seemed much more smooth and flexible, and I'm surprised how relatively easy it was to implement. ?
×

Success!

Help @extinction 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.17,
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,
)...