note 81737 added to function.filectime
| From: | rich at rmbwebs dot com | Date: | Tue, 11 Mar 2008 20:07:22 +0000 |
| Subject: | note 81737 added to function.filectime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136948@lists.php.net to get a copy of this message | ||
This is a modification of simraLIAS at mac dot com's code.
Modification dates should not be used for keys in an array when sorting by date because there is no
guarantee that all files will have different dates. Collisions resulting in files missing from the
list could be possible. A better way is to use the filename as the key (guaranteed to not be
collisions)
<?php
foreach (glob("../downloads/*") as $path) { //configure path
$docs[$path] = filectime($path);
} asort($docs); // sort by value, preserving keys
foreach ($docs as $path => $timestamp) {
print date("d. M. Y: ", $timestamp);
print '<a href="'. $path .'">'. basename($path)
.'</a><br />';
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 66.235.181.123
----
Manual Page -- http://www.php.net/manual/en/function.filectime.php
Edit -- https://master.php.net/note/edit/81737
Del: integrated -- https://master.php.net/note/delete/81737/integrated
Del: useless -- https://master.php.net/note/delete/81737/useless
Del: bad code -- https://master.php.net/note/delete/81737/bad+code
Del: spam -- https://master.php.net/note/delete/81737/spam
Del: non-english -- https://master.php.net/note/delete/81737/non-english
Del: in docs -- https://master.php.net/note/delete/81737/in+docs
Del: other reasons-- https://master.php.net/note/delete/81737
Reject -- https://master.php.net/note/reject/81737
Search -- https://master.php.net/manage/user-notes.php