List files and directories inside the specified path

This bit of code should list all entries in a certain directory:
php start 
function listFolderFiles($dir){
$ffs = scandir($dir);
unset($ffs[array_search('.', $ffs, true)]);
unset($ffs[array_search('..', $ffs, true)]);
// prevent empty ordered elements
if (count($ffs) < 1)
return;
 echo '< ol >';
foreach($ffs as $ff){
echo '< li >'.$ff;
if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);
echo '< /li >';
}
echo '< /ol >';
}

listFolderFiles('FolderPath');

// php end

Comments