I'm already able to list all the file names and current directory/folder but I don't know how to create JSON entries for subdirectories
Here is my code
<?php
$dir = "office/";
if(is_dir($dir)){
if($dh = opendir($dir)){
while(($file = readdir($dh)) != false){
if($file != "." and $file != ".."){
$files_array[] = array('file' => $file); // Add the file to the array
}
}
}
$return_array =array('dir' => $files_array);
exit (json_encode($return_array));
}
?>
and output is
{
"dir": [
{
"file": "FreeWallpapersApp.zip"
},
{
"file": "20151211_ClipArtForTextView.7z"
},
{
"file": "QRite.7z"
},
{
"file": "CustomDialog_app_contacts.zip"
},
{
"file": "LockScreenBasicApp.apk"
},
{
"file": "ImgViewEffects.zip"
},
]
}
How to show files inside subfolder using php to also generate file names which are in subdirectories .