I want my script to put around all the files in a folder, but not around folders in the folder, this is the code I have atm:
function listFolderFiles($dir){
$folder = scandir($dir);
echo "<folder name='".$dir."'>";
foreach($folder as $file){
if($file != '.' && $file != '..'){
if(is_dir($dir.'/'.$file)) {
listFolderFiles($dir.'/'.$file);
}
else{
echo '<file>'.$file.'</file>';
}
}
}
echo "</folder>";
}
I want an output like this:
<folder name='appdata'>
<folder name='appdata/assets'>
<files>
<file>New Text Document - Copy (2) - Copy.txt</file>
<file>New Text Document - Copy (2).txt</file>
<file>New Text Document - Copy.txt</file>
<file>New Text Document.txt</file>
</files>
<folder name='appdata/assets/audio'>
<folder name='appdata/assets/audio/frl'>
<files>
<file>New Microsoft Excel Worksheet - Copy (2).xlsx</file>
<file>New Microsoft Excel Worksheet - Copy - Copy.xlsx</file>
<file>New Microsoft Excel Worksheet - Copy.xlsx</file>
<file>New Microsoft Excel Worksheet.xlsx</file>
</files>
</folder>
</folder>
</folder>
</folder>
Thanks in advance