Home >Backend Development >PHP Tutorial >请教如何查询系统最近5天生成的txt文件并提供链接给访问者上载

请教如何查询系统最近5天生成的txt文件并提供链接给访问者上载

WBOY
WBOYOriginal
2016-06-13 10:50:441119browse

请问怎么查询系统最近5天生成的txt文件并提供链接给访问者下载
系统生成的txt文件都保存在download文件夹下面,请问怎么找出最近5天生成的txt文件,并提供链接给访问者下载
文件的命名是:label+日期时间
Label20120929133440.txt




------解决方案--------------------
$t = date('Ymd', strtotime('-5 day'));
$res = array();
foreach(glob('download/label*.txt') as $fn) {
if(substr($fn, 5, 6) > $t) $res[] = $fn;
}
$res 就是

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn