How to Count Number of Files in Directory using PHP?
In this post, we will learn count number of files in directory php. you can see count number of files in folder php. you'll learn count number of images in folder php. It's a simple example of count number of images in a directory php. Let's see below example php count number of files in directory.
If you are working on code php and you require to count a number of files, images, zip files, rar files, etc in the given folder path, then you can count using glob() and count() of PHP. So, let's see the below example and learn how it did.
$folderPath = "upload/";
$countFile = 0;
$totalFiles = glob($folderPath . "*");
$countFile = count($totalFiles);
I hope it can help you...
We are Recommending you
- PHP - How to convert HTML file to PDF using Dompdf library?
- How to integrate google map using gmaps.js in php example?
- PHP - How to remove duplicate values from multidimensional array?
- How to get current year rows using MySql Query PHP?
- How to get filename without extension in PHP?
- How to remove white space from string in PHP?
- How to check word exist in string or not in PHP?
- How to get current page url in PHP?
- How to get php.ini file path?
- How to Convert Array Values to Lowercase in PHP?
- How to Get Maximum Key Value of Array in PHP?
- How to Get Minimum Key Value of Array in PHP?
- How to Get Product using Rakuten Marketing API in PHP?
- How to Remove Null Values from Array in PHP?