I've got a directory of Word doc's all named 12th March 2001.doc, 18th March 2001.doc -- is there are way to return these using opendir and readdir sorted by date?
Should I be using natsort and if so, how?
well, you can read the directory into an array and then sort the array in the way you would like it and work with it that way.
<? if ($dir = @opendir("yourdir")) { while($file = readdir($dir) && eregi("([0-9]{1,2})", $file, $regs)) { $file_list[$regs[1]]=$file; } closedir($dir); } ksort ($file_list); reset ($file_list);
Thanks, but I'm still getting:
Warning: Wrong datatype in ksort() call Warning: Variable passed to reset()
errors.
I've encountered these before trying others methods to produce the same result.
Any ideas on where it's going wrong?