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

1 Answer

+1 vote
by (54.5k points)

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));

?>


...