Jump to content

[SOLVED] Trying to read a contents of a dir inside a dir


purencool

Recommended Posts

Hi phpfreaks

 

I am trying to display the contents of a directory and if inside that directory another directory is found it will display that contents as well. My issue is  I can the contents of the original directory but  when I try and access a directory inside the original I get errors.

This is what I have so far. I think I am using the wrong function does any one know?

    global $PAGES_DIR; //taken from the config.php
    $dirname = $PAGES_DIR;

    $dirOne = opendir($dirname );
    while (($fileOne = readdir($dirOne)) !== false) {
        echo "filename: " . $fileOne . "<br />";
            if (is_dir ($fileOne)){
                    $fileOne = $dirTwo;
                    echo $dirTwo."<br>";
                    $openDirTwo = opendir($dirTwo );
                    while (($fileTwo = readdir($OpenDirTwo)) !== false) {
                     echo "filename: " . $fileTwo . "<br />";
                    }
                    closedir($openDirTwo);
            }

    }
    closedir($dirOne);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.