教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php按文件生成时间排序列出目录下的所有文件

php按文件生成时间排序列出目录下的所有文件

发布时间:2016-10-15   编辑:jiaochengji.com
教程集为您提供php按文件生成时间排序列出目录下的所有文件等资源,欢迎您收藏本站,我们将为您提供最新的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>’;

打印结果:

\'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('copy1687')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1687> <pre>Array ( [1] => 第十五课.ass [2] => 第二十一课.ass [3] => 第二十课.ass [4] => 第九课.ass [5] => 第二十六课.ass [6] => 第四课.ass [7] => 第十七课.ass [8] => 第二十二课.ass [9] => 第七课.ass [10] => 第三课.ass [11] => 第十八课.ass )</pre>

您可能感兴趣的文章:
php按文件生成时间排序列出目录下的所有文件
PHP遍历目录下的TXT文件且按时间排序
GridView控件事件详细解析
php代码生成器好用吗
xcopy命令批处理拷贝文件或文件夹
dedecms中tag列表按最新发布时间排序的解决方法
php实现对文件夹目录中的文件进行排序的方法
php 列出目录下所有文件(按字母降序排列文件名)
PHP 文件系统详解(推荐)
php程序员面试题分享

[关闭]
~ ~