Advertisement
Ironix

Wer kann helfen ?

Apr 22nd, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. Ich bekomme entweder Fehler oder aber eine weie Seite??
  2. Mchte halt Datei-, Ordnerzahl und deren Gesamtgre..
  3.  
  4.  
  5. <?
  6.  
  7. $dir = '.';
  8.  
  9. chdir($dir);
  10.  
  11.  
  12.  
  13. $scanned = scandir($dir);
  14.  
  15.  
  16.  
  17. // get cumulated file size
  18.  
  19. $du = array_reduce(
  20.  
  21.     $scanned,
  22.    
  23.     function($accu, $dir_entry) {
  24.  
  25.         return is_file($dir_entry) && is_int($fsize = filesize($dir_entry))
  26.  
  27.             ? $accu + $fsize
  28.    
  29.             : $accu;
  30.  
  31.    },
  32.  
  33.    0
  34.  
  35. );
  36.  
  37.  
  38.  
  39. // get number of files (only)
  40.  
  41. $num_files = array_reduce(
  42.  
  43.     $scanned,
  44.  
  45.     function($accu, $dir_entry) {
  46.  
  47.         return $accu + (is_file($dir_entry) ? 1 : 0);
  48.  
  49.     },
  50.  
  51.     0
  52.  
  53. );
  54.  
  55.  
  56.  
  57. printf('directory usage: %s bytes', $du);
  58.  
  59. printf('number of files: %s', $num_files);  
  60.  
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement