我正在尝试将此字节转换为图像主机的千兆字节,请帮助并感谢您,抱歉英语不好:
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[0];
$count = $count + $new_foldersize[1];
}else if(is_file($dir."/".$filename)){
$count_size = $count_size + filesize($dir."/".$filename);
$count++;
}
}
}
return array($count_size,$count);
}
$sample = foldersize("images");
echo "" . $sample[1] . " images hosted " ;
echo "" . $sample[0] . " total space used </br>" ;