Hey there everyone, I'm trying to grab the name of the most recently modified jpg file out of a folder that has the string '_thumb_100' in it. I've gotten this far, but it's getting unpredictable results, which aren't always correct. Anybody have a clue whats not working on this? Thanks!
<?
function flist($path, $ext) {
$flist = array();
$dh = opendir($path);
if (!is_array($ext)) $ext = array($ext);
while (false !== ($file = readdir($dh)))
if (preg_match("/.([^.]*)$/", $file, $get_ext))
if (in_array($get_ext[1], $ext))
$flist[] = $file;
return $flist;
}
$array = array();
chdir('/home/blah/blah');
foreach (flist(getcwd(), 'jpg') as $file) {
if (eregi("_thumb_100", $file)) {
$dm = stat($file);
$array[] = array($file,$dm[9]);
}
}
array_multisort ($array[0],SORT_DESC);
array_reverse($array);
echo $array[0][0];
?>