|
Posted by Tim Roberts on 10/12/06 05:48
"comp.lang.php" <phillip.s.powell@gmail.com> wrote:
>
>petersprc@gmail.com wrote:
>> To expand a wildcard pattern, try the glob function. unlink isn't able
>> to handle wildcards. For instance:
>>
>> $zips = glob("$theDir/*.zip");
>> if ($zips === false) {
>> die("glob failed.");
>> }
>> foreach ($zips as $zip) {
>> unlink($zip) or die("unlink failed.");
>> }
>
>Thanx but how efficient is that? You could be looping through a
>directory potentially containing thousands of images within my
>application each time you display a list of them
You shouldn't worry too much about efficiency until you try it. Try doing
an "ls *.zip" from a command line; the "glob" is going to take roughly the
same time. The Unix directory APIs are pretty efficient.
On the other hand, once you get into "thousands" of images, you might
consider some clever subdirectories. I have a client that stores PDF and
JPG files, where the names have the form 'p12345.pdf'. I use mod_rewrite
to change that to a directory tree p1/23/p12345.pdf. That way, there are
no more than 100 files per directory.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
[Back to original message]
|