Reply to Re: is_dir problem (newbie)...

Your name:

Reply:


Posted by Bruce Spainhower on 06/09/05 00:51

Thanks Andy! That did the trick. Makes perfect sense. It's one of those
things that hides right in front your nose when switching to a new
language.

- Bruce

Andy Hassall <andy@andyh.co.uk> wrote in
news:tqfea1p074cpiom0u17i8edf9ier0kgi8n@4ax.com:

> On Wed, 08 Jun 2005 12:10:17 -0500, Bruce Spainhower
><bruce@focalpointsystems.com> wrote:
>
>>Using the following code...
>>
>> $pathname = ".";
>>
>> $dh = opendir($pathname);
>> while (($dirname = readdir($dh)) !== false) {
>> if (is_dir($dirname)) $dirs[] = $dirname;
>> }
>> closedir($dh);
>>
>> echo "<pre>\n";
>> print_r($dirs);
>> echo "</pre>\n";
>>
>>...I get a correct listing of directories under the current directory.
>>For any other $pathname, (e.g. "./MySub/", "/Temp", "AnotherSub") the
>>only thing returned is:
>>
>>Array
>>(
>> [0] => .
>> [1] => ..
>>)
>>
>>even though there are directories within those directories. I've tried
>>this on both Windows and Linux boxes - same results. Suggestions?
>
> readdir() produces filenames _relative to the directory it's scanning_.
>
> Your is_dir() calls will therefore only work when $pathname is the
> current
> directory. You likely want something more like:
>
> if (is_dir("$pathname/$dirname")) $dirs[] = $dirname;
>

[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

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