Given a title

$path = 'articles/001.html';

I'm able to see if this type of file is available like so:

if ( file_exists( $path ) ) {
    // include it
} else {
    // redirect to articles index

However, I believed about modifying the URL of this article with the addition of the title of this article into it. So, when the user demands this URL:


I must transform the Hyperlink to this:


Now, this obviously implies that I must keep title of this article (and all sorts of other articles) somewhere. The title is situated within the <h1> element of this article, however i doubt that reading through the content (file) around the server simply to retrieve the title may be beneficial.

So, I believed about putting the title within the file title like so:


I Quickly could just extract it in the file title and combine it with the URL. However, I am unsure how to see if this type of file is available within the articles directory - all I acquired may be the article ID (001 within this situation).

So, according to an ID, I must see if there is available an HTML page within the articles directory that begins with this ID, and when yes, I must retrieve its file title.

Is this done? Is a good idea? Suggestions are welcome.

[cde] can match files based on a pattern for you personally:


It offers a superior back a range of all matched up files.