You are here: Re: Faster read of filenames « PHP Programming Language « IT news, forums, messages
Re: Faster read of filenames

Posted by Sonnich on 10/31/06 14:57

Jeff North wrote:
> On 31 Oct 2006 03:22:03 -0800, in comp.lang.php "Sonnich"
> <sonnich.jensen@elektrobit.com>
> <1162293723.742405.257780@e3g2000cwe.googlegroups.com> 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";
> }


That might do it, but it is case sensitive. And when trying something
like:

foreach (glob($search, GLOB_BRACE ) as $filename)
{
echo "$filename <br>";
}

I get absolutlely nothing. My search paths are something like:
\\server\somewhere\AB123*.pdf or \\server\somewhere\AB123*.PDF
Both returns a number of files when runned alone, but adding them
togther
$sx = "{".$s1.",".$s2."}";
does not do the trick.

BR
Sonnich

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация