$path = '/path/to/directory'; if (is_dir($path)) { echo "Directory exists."; } else { echo "Directory does not exist."; }
$dir = '/path/to/directory'; if (is_dir($dir)) { $files = scandir($dir); foreach ($files as $file) { if (is_dir($dir . '/' . $file) && $file != '.' && $file != '..') { echo $file . 'In this example, we are listing all the directories that are present inside a directory located at the path '/path/to/directory'. For this, we first check if the given path is a directory or not. If it is a directory, we then use the scandir() function to get a list of all the files and directories present inside that directory. We then loop through all the files and directories and check if it is a directory or not. If it is a directory, we display its name. The '.' and '..' entries are ignored. The oc.files Filesystem library is a part of the Nextcloud project. It provides an object-oriented interface for accessing files and directories on the Nextcloud instance.
'; } } }