views:

262

answers:

4

Hi,

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

A: 

With scandir() you cannot.

Check this

NinethSense
A: 

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)); }

Deepak
A: 

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

MaxVT
A: 

you could try backticks

$listOfFiles = `ls -ltr`;

and then use explode to get the into an array format

Phill Pafford