Is there a PHP library or framework that provides pre-built solutions for creating collapsible directory trees on a website?

To create collapsible directory trees on a website using PHP, you can utilize the jQuery Treeview plugin along with PHP to generate the tree structure dynamically. This plugin allows you to easily create collapsible tree structures with expand/collapse functionality.

<?php
// Sample PHP code to generate a collapsible directory tree using jQuery Treeview plugin

// Define the directory structure as an array
$directory_tree = array(
    'Folder 1' => array(
        'Subfolder 1',
        'Subfolder 2'
    ),
    'Folder 2' => array(
        'Subfolder 3',
        'Subfolder 4'
    )
);

// Function to recursively generate the directory tree
function generate_directory_tree($tree) {
    echo '<ul>';
    foreach ($tree as $key => $value) {
        echo '<li><span class="folder">' . $key . '</span>';
        if (is_array($value)) {
            generate_directory_tree($value);
        }
        echo '</li>';
    }
    echo '</ul>';
}

// Output the directory tree
generate_directory_tree($directory_tree);
?>