基本信息
源码名称:关于php的遍历目录
源码大小:1.03KB
文件格式:.php
开发语言:PHP
更新时间:2021-12-23
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
php中的遍历目录
<?php
echo"<style>";
echo"table{width:700px;margin:0 auto;}";
echo"table th{background:#0066ff;color:#ffffff;line-height:25px}";
echo"table td{background:#eee;color:#000;line-height:25px}";
echo"< yle>";
function findDir($dirName){
$num=0;
$dir_handle=opendir($dirName);
echo'<table>';
echo'<caption><h2>目录'.$dirName.'下的文件</h2></caption>';
echo'<tr>';
echo'<th>文件名</th><th>文件大小</th><th>文件类型</th><th>修改时间</th></tr>';
while($file=readdir($dir_handle)){
$dirFile=$dirName.'/'.$file;
$num ;
echo'<tr>';
echo'<td>'.$file.'</td>';
echo'<td>'.filesize($dirFile).'</td>';
echo'<td>'.filetype($dirFile).'</td>';
echo'<td>'.date('Y/n/t',filemtime($dirFile)).'</td>';
echo'</tr>';
}
echo"<tr><th colspan='4'>在 $dirName 目录下共有 $num 个子文件;
</th></tr>";
echo"</table>";
closedir($dir_handle);
}
findDir('../file');
?>
php中的遍历目录
<?php
echo"<style>";
echo"table{width:700px;margin:0 auto;}";
echo"table th{background:#0066ff;color:#ffffff;line-height:25px}";
echo"table td{background:#eee;color:#000;line-height:25px}";
echo"< yle>";
function findDir($dirName){
$num=0;
$dir_handle=opendir($dirName);
echo'<table>';
echo'<caption><h2>目录'.$dirName.'下的文件</h2></caption>';
echo'<tr>';
echo'<th>文件名</th><th>文件大小</th><th>文件类型</th><th>修改时间</th></tr>';
while($file=readdir($dir_handle)){
$dirFile=$dirName.'/'.$file;
$num ;
echo'<tr>';
echo'<td>'.$file.'</td>';
echo'<td>'.filesize($dirFile).'</td>';
echo'<td>'.filetype($dirFile).'</td>';
echo'<td>'.date('Y/n/t',filemtime($dirFile)).'</td>';
echo'</tr>';
}
echo"<tr><th colspan='4'>在 $dirName 目录下共有 $num 个子文件;
</th></tr>";
echo"</table>";
closedir($dir_handle);
}
findDir('../file');
?>