Hello all users, i need a little help understanding how to accomplish this task

i need a script that will list all the files in all the folders to look.

say i have these in my folder:

index.php
about.php
folder/file.php
another/anotherfile.php

etc etc

if anyone can help me out that would be fantastic.

Thanks a mill.

    Try this..

    <?php
    $dir = "./";    //Change your directory if needed. Also you can use $_GET and include link to browse your directory..
    
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                echo "File: $file    | Type : " . filetype($dir . $file) . "<br>\n";
            }
            closedir($dh);
        }
    }
    ?>

      If you want to recursively go through all sub-directories, you can do something like:

      <?php
      
      function recurseDir($dir)
      {
         if(!is_dir($dir))
         {
            user_error("Invalid directory");
            return false;
         }
         $result = array();
         $files = glob($dir . '/*');
         foreach($files as $file)
         {
            if(is_dir($file))
            {
               $result[] = recurseDir($file);
            }
            else
            {
               $result[] = $file;
            }
         }
         return $result;
      }
      
      $test = recurseDir('.');
      printf("<pre>%s</pre>", print_r($test, 1));
      ?>
      
        Write a Reply...