在目录中获取最新文件

在目录中获取最新文件,第1张

在目录中获取最新文件
$path = "/path/to/my/dir";$latest_ctime = 0;$latest_filename = '';$d = dir($path);while (false !== ($entry = $d->read())) {  $filepath = "{$path}/{$entry}";  // could do also other checks than just checking whether the entry is a file  if (is_file($filepath) && filectime($filepath) > $latest_ctime) {    $latest_ctime = filectime($filepath);    $latest_filename = $entry;  }}// now $latest_filename contains the filename of the file that changed last


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5441571.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存