Skip to content

Instantly share code, notes, and snippets.

@2803media
Created May 21, 2015 10:36
Show Gist options
  • Select an option

  • Save 2803media/93982e83c3574fc914dd to your computer and use it in GitHub Desktop.

Select an option

Save 2803media/93982e83c3574fc914dd to your computer and use it in GitHub Desktop.
function folderSize($dir){
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
foreach($dir_array as $key=>$filename){
if($filename!=".." && $filename!="."){
if(is_dir($dir."/".$filename)){
$new_foldersize = foldersize($dir."/".$filename);
$count_size = $count_size+ $new_foldersize;
}else if(is_file($dir."/".$filename)){
$count_size = $count_size + filesize($dir."/".$filename);
$count++;
}
}
}
return $count_size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment