Re: Faster read of filenames
- From: Pedro Graca <hexkid@xxxxxxxxxxx>
- Date: 31 Oct 2006 13:17:02 GMT
Sonnich wrote:
I use the opendir and readdir to search for files... but they read in
all files, so sometimes I get several hundreds.
If there is a way to give a wildcard, it might be a lot faster.
Since I do this search 100+ times at certain times, this is the thing
which slows me down.
Disableing this part speeds my code up by 90%.
Any ideas?
glob()? http://php.net/glob
If your files do not change very often, it may be better to have a
file (or database) with the current files and use that instead of
searching in the file system.
<?php
$filelist = file($path . '/filelist.txt');
foreach ($filelist as $fname) {
$files[] = trim($fname);
$paths[] = $path;
}
?>
Of course you'd have to keep filelist.txt updated.
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
.
- References:
- Faster read of filenames
- From: Sonnich
- Faster read of filenames
- Prev by Date: Re: php script to create mySQL database programmatically
- Next by Date: Re: php script to create mySQL database programmatically
- Previous by thread: Re: Faster read of filenames
- Next by thread: php script to create mySQL database programmatically
- Index(es):