コードをコピー コードは次のとおりです。
header('content-type:text/html; charset=utf -8');
関数 delFile($fpath) {
$filesize = array();
$filepath = iconv('gb2312', 'utf-8', $fpath);
if (is_dir($fpath)) {
if ($dh = opendir($fpath)) {
while (($file = readdir($dh)) !== false) {
if( $file != '.' && $file != '..') {
$filesize[] = delFile($fpath.'/'.$file)
}
Closedir($dh);
}
/*
* ディレクトリの数を数えるのに便利
*/
$filesize['file'] = 0; if(@rmdir($ fpath) === true) {
echo "{$filepath}....正常に削除されました
n"
} else {
echo "{$filepath}....削除に失敗しました
n";
}
} else {
if(is_file($ fpath)) {
$filesize[] = $fsize = filesize($fpath);
if(@unlink($fpath) === true) {
echo "{$filepath}... {$fsize} K....正常に削除されました
n";
} else {
echo "{$filepath}...{$ fsize}K.... ......削除に失敗しました
n";
}
}
}
return $filesize;
}
/*
* function getArrSum(array &$arr) 配列の合計
* 配列 &$arr 処理された配列
*/
function getArrSum(&$arr) {
if(is_array($arr)) {
foreach ($ arr as &$value) {
$value = getArrSum($value);
return array_sum($arr); else {
return $arr;
}
$fpath = 'D:/test';
$filesize = getArrSum($filesize);
printf(' %.3fM space', $size/(1024*1024));
?>
D ドライブの下にテスト フォルダーを作成し、そこにコピーします。テスト。