Skip to content

Instantly share code, notes, and snippets.

@aice09
Created February 24, 2021 01:43
Show Gist options
  • Save aice09/d26d022746cbd04e95c4061855cc90df to your computer and use it in GitHub Desktop.
Save aice09/d26d022746cbd04e95c4061855cc90df to your computer and use it in GitHub Desktop.
<?php
$genpath = "../fileshere/";
$category = "Folder Test 1";
$folder = scandir($genpath . $category);
$files = array_diff($folder, array(
'.',
'..',
'.metadata'
));
$a = "<ul>";
foreach ($files as $file) {
$a .= "<li>" . $file . "</li>";
if ($file === '.' or $file === '..') {
continue;
} else {
$a .= "<ul>";
$xfolder = scandir($genpath . $category . '/' . $file);
$xfiles = array_diff($xfolder, array(
'.',
'..',
'.metadata'
));
foreach ($xfiles as $key) {
if ($key === '.' or $key === '..') {
continue;
} else {
$a .= "<li>" . $key . "</li>";
}
}
$a .= "</ul>";
}
}
$a .= "</ul>";
echo $a;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment