Re: listing directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> if ($dir = opendir($path))
> {
>     while($file = readdir($dir))
>     {
>         if ($file != "." && $file != "..")
>         {
>         echo "$file";
>             if (is_dir($file))

USE: is_dir("$path/$file") to get the full pathname so that PHP has some
idea *which* directory it's supposed to be looking at.

Don't make it guess.

>             {
>                 echo ' <- folder<br>';
>             }
>             elseif (is_file($file))
>             {
>                 echo ' <- file<br>';
>             }
>             else
>             {
>                 echo ' <- ????????<br>';
>             }
>         }
>     }
>     closedir($dir);
> }
>
> But is_dir($file) doen't recognize the directory EVERY TIME.
>
> E.g.
>
> log <- folder
> CSVs <- folder
> php_images <- ????????
> admin <- ????????
> images <- folder
> includes <- folder
>
> and "php_images" and "admin" are direktories too.
>
> In directory with folders (named after product number) didn't recognize
> ANY.
>
> 22 <- ????????
> 54 <- ????????
> 86 <- ????????
> 91 <- ????????
> 94 <- ????????
> 97 <- ????????
> CD <- ????????
> F4 <- ????????
> W1 <- ????????
> 690000-05 <- ????????
> 107 <- ????????
> 113 <- ????????
> 150 <- ????????
> 220 <- ????????
> 221 <- ????????
>
> What am I doing wrong?
>
> Thanks.
>
> -afan
>
>
> Fernando Gutierrez wrote:
>
>>http://es.php.net/manual/en/function.opendir.php
>>
>>
>>On Tue, 15 Mar 2005 10:00:19 -0600, afan@xxxxxxxx <afan@xxxxxxxx> wrote:
>>
>>
>>>Hi guys,
>>>Few days ago somebody asked something about listing content of
>>>directories and subdirectories.
>>>How I can get answers on this queastion? I have a same problem and don't
>>>want to bother you again with same thing :)
>>>
>>>Thanks
>>>
>>>-afan
>>>
>>>--
>>>PHP General Mailing List (http://www.php.net/)
>>>To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux