Dynamically I am creating sub directory in a folder and I need to get the last created directory in a sting format, I have tried many ways but failed to get it. What i have tried is,
$path = "/path/to/my/dir";
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
But it works for only file. Thanks in advance.