[Solved] display files and folders in php (file handeling)


Please check this:

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;

   foreach($ffs as $ff){       
       if(is_dir($dir."https://stackoverflow.com/".$ff)){
          echo '+'.$ff ."<br>";
          listFolderFiles($dir."https://stackoverflow.com/".$ff);
       } else {
          echo '-'.$ff ."<br>";
       }
   }
}

listFolderFiles('C:\xampp\htdocs\ic');

solved display files and folders in php (file handeling)