Educating the world

Our blog has over 10,000 readers a month

« rm: Argument list too longPlesk Awstat forgets the monthly statistics »

4 comments

Comment from: Andrew [Visitor]
Andrew

Thank you - I like option 2 for php. Is there an easy way to incorporate the following code to sort the index page files by date? This would be useful for sites to list the most recent files near the top.

I see there is code like this but it’s not complete (from php.net/opendir ):

[codeblock lang="php” line="1″]
$content_array = array();

//set current working directory
$dirname = “C:\temp";

//Load Directory Into Array
$handle=opendir($dirname);
$i=0;
while ($file = readdir($handle))
if ($file != “.” && $file != “..")
{
$content_array[$i][0] = $file;
$content_array[$i][1] = date ("Y m d", filemtime($dirname."/".$file));
$i++;
}
//close the directory handle
closedir($handle);

// these lines sort the contents of the directory by the date
foreach($content_array as $res)
$sortAux[] = $res[1];
array_multisort($sortAux, SORT_ASC, $content_array);
[/codeblock]

01/10/08 @ 14:37
Comment from: Wiboon Warasittichai [Visitor]
Wiboon Warasittichai

Can you make directory list in a drop-down menu? Thanks.

10/10/08 @ 08:19
Comment from: davidnewcomb [Member]  
admin

Yes - you can!

10/10/08 @ 11:00
Comment from: Dretoot [Visitor]
Dretoot

Your writing is very elegant, very vivid and lively, I really like you, wish you continued to write better articles, I will often try to concern, oh!

24/03/10 @ 08:26

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
  
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)