You are here: Re: only list dirs if they have jpgs inside « PHP Programming Language « IT news, forums, messages
Re: only list dirs if they have jpgs inside

Posted by J. Frank Parnell on 08/01/07 19:31

On Wed, 1 Aug 2007 12:55:46 +0100, Toby A Inkster
<usenet200707@tobyinkster.co.uk> wrote:

>J. Frank Parnell wrote:
>
>> I got this directory tree listing function somewhere, it works great,
>> but I want it to only list directories that do have one or more .jpgs
>> inside.
>
>It's a bit of a cheat, but...
>
><?php
>function find_dirs_with_jpegs ($path)
>{
> $path = addslashes($path);
> $find = "find '{$path}' -iregex '.*\\.jpe?g' -printf '%h\\n'";
> $dirs = explode("\n", `$find | sort -u`);
> array_pop($dirs);
> return $dirs;
>}
>?>

Since i have php4, i tried this (thanks anyway Michael Fesser).

Works great, thanks! Could you explain 'bit of a cheat'? Am I going to get
caught? :)

I'm using this on a dir with about 4500 dirs, about 3300 of which have jpgs(the
rest are mostly ancestors of the jpg dirs), according to this func (which
matches what i came up with using my getDirlistAndForeachLookingForJpgs().)
find_dirs_with_jpegs () seems faster, though i didnt scientifically test it.

 

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

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