+4 votes
in Programming Languages by (40.5k points)
I want to list all files and directories inside a directory. What PHP function should I use for it?

1 Answer

+2 votes
by (71.8k points)
selected by
 
Best answer

You can use the PHP function scandir() to get all files and directories present inside a directory.

Here is an example

<?php

$dir = "path_to_your_directory/";

print_r(scandir($dir));

?>


...