Jump to content

displaying directory


Maverickb7

Recommended Posts

I'm going to assume you meant file names and not data. ;)

[code]
<?php
  $i = 0;
  $path = 'my_directory';
  $dir=opendir($path);
  while ($file=readdir($dir))
  {
      if ($file != "." && $file != ".." && is_file($file) )
      {
        $my_file_array[$i] = $file;
        $i++;
      }
  }
?>
[/code]

I'm also going to assume you wanted only files in there and not folders. If this is incorrect, simply remove [code=php:0]&& is_file($file)[/code] from the [code=php:0]if[/code] statement!
Link to comment
https://forums.phpfreaks.com/topic/23623-displaying-directory/#findComment-107278
Share on other sites

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.