Hello how can i modify this script to search in all subdirectories to get only one new directory? THX!
This little script only search in current $path for newest directory but i also need to search in all subdirectories
<?php
function getNewestDir($path) {
$working_dir = getcwd();
chdir($path); ## chdir to requested dir
$ret_val = false;
if ($p = opendir($path) ) {
while (false !== ($file = readdir($p))) {
if ($file{0} != '.' && is_dir($file)) {
$list[] = date('YmdHis', filemtime($path.'/'.$file)).$path.'/'.$file;
}
}
rsort($list);
$ret_val = $list[0];
}
chdir($working_dir); ## chdir back to script's dir
return $ret_val;
}
?>