What is the best approach to implement a tree structure like the one in MS-Explorer using PHP?

To implement a tree structure like the one in MS-Explorer using PHP, you can use a recursive function to traverse through the tree nodes and display them in a hierarchical manner. You will need to store the tree structure in a multidimensional array or a database table with parent-child relationships.

<?php
// Sample tree structure
$tree = [
    'folder1' => [
        'file1',
        'file2',
        'subfolder1' => [
            'file3',
            'file4'
        ]
    ],
    'folder2' => [
        'file5'
    ]
];

function displayTree($tree, $indent = 0) {
    foreach ($tree as $key => $value) {
        if (is_array($value)) {
            echo str_repeat('  ', $indent) . $key . "<br>";
            displayTree($value, $indent + 1);
        } else {
            echo str_repeat('  ', $indent) . $value . "<br>";
        }
    }
}

displayTree($tree);
?>