How to Get All Files in a Directory in PHP – Programming Code Examples

How to Get All Files in a Directory in PHP2 min read

In this example,I will show you how to how to get all files in a folder using PHP Language. You can esay and simply get list of files in Folder in PHP.

We use the built-in function scandir() to take files name from a directory.

The scandir() function lists the files and directories names which are present inside a specified path.

scandir():The scandir() function in PHP is an inbuilt function which is used to return an array of files and directories of the specified directory.

Example 1:


Example 2:


Example 3: Php list all files in directory recursively


Example 4: Get File names form Current Directory


Example 5: Get file name from directory


Leave a Comment