note 31666 added to function.readdir

From: Date: Tue, 29 Apr 2003 20:29:51 +0000
Subject: note 31666 added to function.readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-47256@lists.php.net to get a copy of this message
On sorting by date- no, you can't just use an associative array since some things /will/ be created on the same second. No reason why you can't append the filename to the time, though! (used md5() to kill any weird characters in a unique way) $dirpath = getcwd() . "/"; $dir = opendir($dirpath); $files = array(); while ($file = readdir($dir)) { $localpath = $dirpath.$file; if (is_file($localpath)) { $key = filemtime($localpath).md5($file); $files[$key] = $file; } } ksort($files); foreach ($files as $file) { echo "$file<br>"; } -- http://www.php.net/manual/en/function.readdir.php http://master.php.net/manage/user-notes.php?action=edit+31666 http://master.php.net/manage/user-notes.php?action=delete+31666 http://master.php.net/manage/user-notes.php?action=reject+31666

« previous php.notes (#47256) next »