$dir = "/path/to/directory"; $contents = scandir($dir); print_r($contents);
$dir = "/path/to/directory"; $files = array_diff(scandir($dir), array('.', '..')); print_r($files);
$dir = "/path/to/directory"; $subdirs = array_filter(glob($dir . '/*'), 'is_dir'); print_r($subdirs);This code example retrieves only the subdirectories contained in the directory specified in the `$dir` variable. The `glob()` function returns an array of all the files and subdirectories in the specified directory, and the `is_dir()` function filters out the files, leaving only the subdirectories. Package Library: The "glob()" function belongs to the core PHP library.