PHP:在文件夹中检索和显示(HTML)最新的图像文件
我想扫描一个文件夹,按修改时间对该文件夹中的文件进行排序,并显示最近的文件。以下是我目前掌握的情况:PHP:在文件夹中检索和显示(HTML)最新的图像文件,html,scandir,Html,Scandir,我想扫描一个文件夹,按修改时间对该文件夹中的文件进行排序,并显示最近的文件。以下是我目前掌握的情况: <?php function scanDir ($dir){ $fileTimeArray = array(); // Scan directory and get each file date foreach (scandir($dir) as $fileTime){ $fileTimeArray[$fileTime] = filemtime
<?php
function scanDir ($dir){
$fileTimeArray = array();
// Scan directory and get each file date
foreach (scandir($dir) as $fileTime){
$fileTimeArray[$fileTime] = filemtime($dir . '/' . $fileTime);
}
//Sort file times
$fileTimeArray = arsort($fileTimeArray);
return($fileTimeArray[0]);
}
?>
我在另一个php文件中调用这个函数,在img标记的src中
到目前为止
<img src=Array>
我在函数中哪里出错了?谢谢你