Reply to Re: file_exists and thousand of files

Your name:

Reply:


Posted by Chung Leong on 06/13/06 14:28

Erwin Moller wrote:
> I think you could do a general faster job by trying to match a substring to
> the filename in a certain directory, and do it once, not 10 times.
> That is sometimes refered to as 'globbing'.
> I know this from Perl, but I just saw it exists in PHP under the name....
> glob. What a surpise. ;-)

Somehow I doubt you can do a better job than the OS. Typically a binary
search is used for directory look-up. Finding one file amidst a
thousand wouldn't take more than 10 string comparisons. So for ten
look-ups the OS would do no more than 100 comparisons. Unless you write
a b-search routine in PHP yourself, you'll certainly do worse. A search
with in_array() or array_search() would require on average 500
comparisons per look-up. With a hash-table it's better, but then the
construction of it would require generating a 1000 hash keys. And if
you're on Windows you have case-sensitivity to consider...

[Back to original 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

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