Re: Faster read of filenames
- From: Jeff North <jnorthau@xxxxxxxxxxxx>
- Date: Tue, 31 Oct 2006 12:46:27 GMT
On 31 Oct 2006 03:22:03 -0800, in comp.lang.php "Sonnich"
<sonnich.jensen@xxxxxxxxxxxxxx>
<1162293723.742405.257780@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
| Hi all
|
| 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?
|
| Sonnich
|
|
| if($handle = opendir($sSearchPath))
| {
| while (false !== ($file = readdir($handle)))
| {
| $file2 = strtoupper($file);
| if( (strpos($file2, $code)!==False) && (strpos($file2,
| ".PDF")!==False))
| {
| $files[] = $file;
| $paths[] = $sSearchPath;
| }
| }
| closedir($handle);
| }
glob() maybe?
foreach (glob("*.txt") as $filename)
{
echo "$filename size " . filesize($filename) . "\n";
}
---------------------------------------------------------------
jnorthau@xxxxxxxxxxxxxxxxxxxxx : Remove your pants to reply
---------------------------------------------------------------
.
- 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: Faster read of filenames
- Next by thread: Re: Faster read of filenames
- Index(es):
Relevant Pages
|