What PHP function can be used to count files with a specific extension in a directory?
To count files with a specific extension in a directory using PHP, you can use the `glob` function to retrieve an array of file names matching a specified pattern, and then count the elements in that array. You can specify the directory path and the file extension pattern to filter the files you want to count.
$directory = '/path/to/directory/';
$extension = '*.txt'; // Specify the file extension you want to count
$files = glob($directory . $extension);
$fileCount = count($files);
echo "Number of {$extension} files in {$directory}: {$fileCount}";