<?php
/**
* 循环获取文件
*/
function getExt1($filename)
{
$arr = explode('.',$filename);
return array_pop($arr);
}
function trans_byte($byte)
{
$KB = 1024;
$MB = 1024 * $KB;
$GB = 1024 * $MB;
$TB = 1024 * $GB;
if ($byte < $KB) {
return $byte . "B";
} elseif ($byte < $MB) {
return round($byte / $KB, 2) . "KB";
} elseif ($byte < $GB) {
return round($byte / $MB, 2) . "MB";
} elseif ($byte < $TB) {
return round($byte / $GB, 2) . "GB";
} else {
return round($byte / $TB, 2) . "TB";
}
}
function scan_dir($dir) {
$sum = 0 ;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if($file=='..' || $file=='.') continue;
if(is_file($dir.'/'.$file)) {
$file_list[] = $dir.'/'.$file;
if(getExt1($dir.'/'.$file)=='txt' && filesize($dir.'/'.$file)<= 5000) {
echo $dir.'/'.$file.' '.trans_byte(filesize($dir.'/'.$file)).' '.filesize($dir.'/'.$file).PHP_EOL;
unlink($dir.'/'.$file);
}
continue;
}
/*
$sum=$sum+ 1 ;
if($sum= 10) {
break;
}*/
$file_list[$file] = $this->scan_dir($dir.'/'.$file);
foreach($file_list[$file] as $infile) {
$file_list[] = $infile;
}
unset($file_list[$file]);
}
closedir($handle);
return $file_list;
}
}
$file = scan_dir('/www/wwwroot/www.xxx.com/');
//var_dump($file);
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询