php按文件生成时间排序列出目录下的所有文件
发布时间:2016-10-15 编辑:jiaochengji.com
教程集为您提供php按文件生成时间排序列出目录下的所有文件等资源,欢迎您收藏本站,我们将为您提供最新的php按文件生成时间排序列出目录下的所有文件资源
本文章为各位介绍php按文件生成时间排序列出目录下的所有文件的例子,有兴趣的朋友不防进入参考。
先看文件列表:
再看代码:
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2017')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2017> $dir=’ass’;
$dp = dir($dir);
while ($file = $dp ->read()){
$filename=$dir.’/’.$file;
if($file!=’.'&&$file!=’..’){
$key=filectime($filename)*1000 rand(100,999);
$files[strval($key)]=$filename;
}
}
echo ‘<pre>’;
print_r($files);
ksort($files);
print_r($files);
$keys = range(1,count($files));
$arr=array_combine($keys,$files);
print_r($arr);
echo ‘</pre>’;
$dp = dir($dir);
while ($file = $dp ->read()){
$filename=$dir.’/’.$file;
if($file!=’.'&&$file!=’..’){
$key=filectime($filename)*1000 rand(100,999);
$files[strval($key)]=$filename;
}
}
echo ‘<pre>’;
print_r($files);
ksort($files);
print_r($files);
$keys = range(1,count($files));
$arr=array_combine($keys,$files);
print_r($arr);
echo ‘</pre>’;
打印结果:
您可能感兴趣的文章:
php按文件生成时间排序列出目录下的所有文件
PHP遍历目录下的TXT文件且按时间排序
GridView控件事件详细解析
php代码生成器好用吗
xcopy命令批处理拷贝文件或文件夹
dedecms中tag列表按最新发布时间排序的解决方法
php实现对文件夹目录中的文件进行排序的方法
php 列出目录下所有文件(按字母降序排列文件名)
PHP 文件系统详解(推荐)
php程序员面试题分享
上一篇:PHP服务器状态监控实现程序
下一篇:php提取网页正文内容的例子
[关闭]