is_dir trouble

    Date: 10/27/05 (PHP Community)    Keywords: no keywords

    I'm trying to write a small script for a friend that will list all of the directories contained in a directory. My function currently looks like this:

    function displayDir($dir)
    {
     $dh  = opendir($dir);
     while (false !== ($filename = readdir($dh))) {
        $files[] = $filename;
     }
     sort($files);
     echo "

    "; foreach($files as $dirName) { if(is_dir($dirName)) echo $dirName . "
    \n"; } echo "

    \n"; }


    When I call the function like so displayDir(getcwd()); it displays all of the directories correctly. However when I try displayDir("test"); (test is a valid directory on my server which contains 11 other directories) is only reutrns back the . .. and one other directory. I've tried taking out the is_dir condition and it returns all of the files located in test just fine. Any idea what's up?

    Source: http://www.livejournal.com/community/php/359541.html

« Hey guys, first post || mysql_connect() not... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home