SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to do this directory combining?

    How would I use opendir to open 5 different directories and order them by descending of the latest file (image type) uploaded?
    Have a good day.

  2. #2
    SitePoint Enthusiast b.anderson's Avatar
    Join Date
    May 2003
    Location
    Chicago
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do something like this...

    PHP Code:

    $dir
    [0] = '/path/to/dir0';
    $dir[1] = '/path/to/dir1';
    $dir[2] = '/path/to/dir2';
    $dir[3] = '/path/to/dir3';
    $dir[4] = '/path/to/dir4';

    $i_dir 0;
    $i 0;

    while(
    $i_dir 5)
    {
        if (
    $handle opendir($dir[$i_dir])) {
           while (
    false !== ($file readdir($handle))) {
               if (
    $file != "." && $file != "..") {
                   
    $file_array[$i,0] = $dir[$i_dir].'/'.$file;
                   
    $file_array[$i,1] = filetime($dir[$i_dir].'/'.$file);
                   
    $i++;
               }
           }
           
    closedir($handle);
        }

        
    $i_dir++;
    }

    array_multisort($file_array[1], sort_desc$file_array[0], sort_asc); 

  3. #3
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks
    Have a good day.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •