fork download
  1. <?php
  2. $path = '/???/???/???/';
  3. foreach(createDir($path) as $html){
  4. echo $html;
  5. }
  6.  
  7. function createDir($path = '.')
  8. {
  9. if ($handle = opendir($path))
  10. {
  11. $queue = array();
  12. $dir_sort = array();
  13. while (false !== ($file = readdir($handle)))
  14. {
  15. if (is_dir($path.$file) && $file != '.' && $file !='..') {
  16. $dir_sort[] = $file;
  17. } else if ($file != '.' && $file !='..') {
  18. $queue[] = $file;
  19. }
  20. }
  21. if (count($dir_sort) > 0){
  22. if (preg_match('/^\d{8}/',$dir_sort[0]) == 1){
  23. rsort($dir_sort,SORT_STRING);
  24. }else{
  25. sort($dir_sort,SORT_STRING);
  26. }
  27. }
  28.  
  29. $html[] = '<ul>';
  30. foreach ($dir_sort as $file)
  31. {
  32. $html[] = '<li><span class="dir"><span class="ion-folder"> '.$file.'</span></span>';
  33. $html = array_merge($html, createDir($path.$file.'/'));
  34. $html[] = '</li>';
  35. }
  36. foreach ($queue as $file)
  37. {
  38. $html[] = '<li><a href='.$path.$file.'><span class="ion-document"> '.$file.'</span></a></li>';
  39. }
  40. $html[] = '</ul>';
  41. return $html;
  42. }
  43. }
  44. ?>
  45.  
Success #stdin #stdout #stderr 0.02s 24492KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  opendir(/???/???/???/): failed to open dir: No such file or directory in /home/EVmuZM/prog.php on line 9
PHP Warning:  Invalid argument supplied for foreach() in /home/EVmuZM/prog.php on line 3