Answers for "how to get all file in a folder using php"

PHP
1

php get all txt files in directory

$path = '/path/to/directory';
$files = glob($path."/*.txt");
foreach ($files as $file) {
  echo $file;
  echo '<br>';
}
/* Outputs something like: 
	/path/to/directory/someFile.txt
	/path/to/directory/someOtherFile.txt
	/path/to/directory/anotherFile.txt
*/
Posted by: Guest on July-24-2021
4

php get all php files in a directory

foreach(glob('includes/*.php') as $file) {
    ...
}
Posted by: Guest on March-21-2020

Code answers related to "how to get all file in a folder using php"

Browse Popular Code Answers by Language