1

我试图以与上次修改时间相反的顺序显示图像。不幸的是, get_headers() 似乎只适用于 url,而 stat['mtime'] 和 filemtime() 对我来说都失败了。我还有其他方法可以获取文件的最后修改信息吗?这是我目前的代码:

if (isset($_GET['start']) && "true" === $_GET['start'])
{
    $images = array();

    if ($dir = dir('images'))
    {
        $count = 0;

        while(false !== ($file = $dir->read()))
        {
            if (!is_dir($file) && $file !== '.' && $file !== '..' && (substr($file, -3) === 'jpg' || substr($file, -3) === 'png' || substr($file, -3) === 'gif'))
            {
                $lastModified = filemtime($file);
                $images[$lastModified] = $file;
                ++$count;
            }
        }

        echo json_encode($images);
    }
    else { echo "Could not open directory"; }
}
4

1 回答 1

2

在调用filemtime($file). 尝试

$lastMod = filemtime("images/".$file);
于 2010-08-04T19:47:56.897 回答