onlinecode

How to count number of files in directory PHP?

How to count number of files in directory PHP?

In this post we will give you information about How to count number of files in directory PHP?. Hear we will give you detail about How to count number of files in directory PHP?And how to use it also give you demo for it if it is necessary.

If you are working on code php and you require to count number of files, images, zip file, rar files, etc in the given folder path, then you can count using glob() and count() of php. So, let’s see this bellow example and learn how it done.

$folderPath = "upload/";

$countFile = 0;

$totalFiles = glob($folderPath . "*");

if ($totalFiles){

$countFile = count($totalFiles);

}

print_r($countFile);

Hope this code and post will helped you for implement How to count number of files in directory PHP?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version