1

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

4

4 回答 4

1

you could try backticks

$listOfFiles = `ls -ltr`;

and then use explode to get the into an array format

于 2009-10-14T12:07:15.437 回答
0

With scandir() you cannot.

Check this

于 2009-10-14T06:59:18.950 回答
0

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));
}
于 2009-10-14T07:10:34.497 回答
0

Get results you need into an array and sort it... I'm not aware of a scandir option that can do this directly.

于 2009-10-14T07:21:35.593 回答