What is the alternative function in PHP to read only folders with a specific extension?

To read only folders with a specific extension in PHP, you can use the `glob()` function with a wildcard pattern to filter out folders based on their extension. By specifying the path to the folder and the extension pattern, you can retrieve only the folders that match the specified extension.

$folders = glob('path/to/folder/*.extension', GLOB_ONLYDIR);

foreach ($folders as $folder) {
    echo $folder . PHP_EOL;
}