문제

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));
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top