answersLogoWhite

0

To list all the files in a directory you would use the following: $handle = opendir('/path/to/folder');

while(($file = readdir($handle)) !== false){

// do things with files

// you will want to filter out things like ., .., and .htaccess

echo $file;

}

Also, to return a list of all the files in a directory, especially with wildcards, use something such as:

$file_array = glob("*"); $files = implode("\n", $file_array);

echo $files;

will give you a list of all the files directly.

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

How do you change the current directory in PHP?

chdir() PHP function helps in changing the current directory.


Can .php files be executed when saved in other location than its web's root directory?

They can execute if you use include or require and show the full path of external php file in the www folder based php file.


What is the command to be used to see all the files in a directory?

The command in a terminal is: ls (short for List). This will list the files in the current directory. Whilst in the Home directory, to list the files in a different directory, for instance Videos, use: ls Videos.


Will php 4.4.7 server support php 5 files?

Yes php 4.4.7 server support php 5 files. But most of the php 5 features are not supported by php 4.4.7 version


Shell programming to list all directory files to a directory?

for i in * do if [ -d $i ]; then echo $i directory >> /tmp/directories fi done


How do you get the current working directory in PHP?

$curr_dir = getcwd();


What is a java directory?

collection of files and directory


Which Linux command will delete a directory as well as all its files and sub directories?

rm -rv /path/to/directory


How do you copy all the files from etc directory to oracle in unix?

You will need to be more clear about the target - is 'oracle' a directory?


How do you decompress PHP files?

PHP isn't generally a compressed file, so it all depends on what format it was compressed into. Hope this has helped, Cpl.Vadera


Can a php file be valid without any php code?

PHP files are HTML files with any amount of PHP intermingled into it, so the file can be empty or only contain HTML and be valid, yes.


What is the command to list all files and sub directories in a directory?

DIR