Function: JScms_get_folders
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


Function: JScms_get_folders

The JScms_get_folders function retrieves all folder names from a specified directory, excluding specific folders if provided.

Syntax


JScms_get_folders(string $dir, string|null $excludeFolder = null): array
    

Parameters

  • $dir: (string) The directory path to scan for folders.
  • $excludeFolder: (string|null) Optional. A folder name to exclude from the results. Default is null.

Returns

(array) An array of folder names found in the specified directory.

Example Usage


<?php
$folders = JScms_get_folders("/path/to/templates", "exclude_folder");
foreach ($folders as $folder) {
    echo $folder . "\n";
}
?>
    

Best Practices

  • Use this function to list directories for dynamic inclusion, such as templates or plugins.
  • Ensure the provided directory path exists and is accessible.

Common Issues

  • Non-Existent Directory: Ensure the specified directory path exists; otherwise, scandir will throw a warning.
  • Permissions: Verify the script has appropriate read permissions for the directory.
Was this article helpful?
0 out of 0 found this helpful