Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #15910

Fast PHP way to find a file given the leftmost characters of the file name

From James Harris <james.harris.1@gmail.com>
Newsgroups comp.lang.php
Subject Fast PHP way to find a file given the leftmost characters of the file name
Date 2015-12-05 17:39 +0000
Organization A noiseless patient Spider
Message-ID <n3v7c9$ko9$1@dont-email.me> (permalink)

Show all headers | View raw


Basic query: What is the best way in PHP to find a file given just the 
leftmost characters of its name? I am looking for something that will 
scale so that it can be expected to execute quickly even if there are 
thousands of files in a given directory.

In more detail: For a new site I am thinking to have long names on files 
and for a PHP script to find a specific file given just the leftmost 
characters of the file's name which it has got from the URL. This is for 
SEO and convenience reasons. The file name would be long so that it 
could reflect the title/subject/topic of the page.

The URL could include the full name (without an extension) or just a 
short prefix. For example, if the file names were

   1001-this-is-a-file.ext1
   1002-this-is-too.ext2
   1003-so-is-this.ext1

the first of those files could be accessed by either of these URLs:

   http://site.com/dir/1001-this-is-a-file
   http://site.com/dir/1001

As you can see, the second name is the short form of the first.

The requests would be directed to a PHP script by URL rewriting. Either 
of the URLs could be used to find the same file.

Note that even the first URL needs to match on the leftmost characters 
as it omits the extension.

In each case I would need to find a file which begins with the string 
specified in the URL. Hence this query.

I guess something like this approach to URL shortening is fairly common 
for SEO reasons. Maybe there is a standard solution...?

Any comments? Even if you think the idea is a bad one I would appreciate 
the feedback.

James

Back to comp.lang.php | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Fast PHP way to find a file given the leftmost characters of the file name James Harris <james.harris.1@gmail.com> - 2015-12-05 17:39 +0000
  Re: Fast PHP way to find a file given the leftmost characters of the file name Arno Welzel <usenet@arnowelzel.de> - 2015-12-05 19:37 +0100
  Re: Fast PHP way to find a file given the leftmost characters of the file name Markus Heinz <markus.heinz@uni-dortmund.de> - 2015-12-05 19:45 +0100
    Re: Fast PHP way to find a file given the leftmost characters of the file name Matthew Carter <m@ahungry.com> - 2015-12-05 14:45 -0500
      Re: Fast PHP way to find a file given the leftmost characters of the file name Jerry Stuckle <jstucklex@attglobal.net> - 2015-12-05 15:53 -0500
      Re: Fast PHP way to find a file given the leftmost characters of the file name James Harris <james.harris.1@gmail.com> - 2015-12-06 00:50 +0000
        Re: Fast PHP way to find a file given the leftmost characters of the file name Matthew Carter <m@ahungry.com> - 2015-12-07 00:17 -0500
          Re: Fast PHP way to find a file given the leftmost characters of the file name James Harris <james.harris.1@gmail.com> - 2015-12-08 11:45 +0000

csiph-web