//open the current directory $directory = opendir('.'); while ($file = readdir($directory)) { $filenames[] = $file; } foreach ($filenames as $file) { echo "$file"; } ?>