How do you get a directory listing sorted by creation date in PHP?
문제
I have to list directories by using scandir() function but result array should be sorted according to date and time of directory created.
Regards Deepak
해결책
you could try backticks
$listOfFiles = `ls -ltr`;
and then use explode to get the into an array format
다른 팁
With scandir() you cannot.
Check this
Get results you need into an array and sort it... I'm not aware of a scandir option that can do this directly.
Problem can be solved by using filemtime($dirPath)
function.
code sample:
if (file_exists($dirPath)) {
echo "last modified: " . date ("F d Y H:i:s.", filemtime($dirPath));
}
제휴하지 않습니다 StackOverflow