Hi all, first post and all. 🙂
Until now, I've had no problems using the following code to get a directory listing of directories into an array for later use:
echo "Step 2 - Scanning Directories...\n";
$d_arr = array();
$d = 0;
if ($handle = opendir($viddir)) {
while (false !== ($file = readdir($handle))) {
if(is_dir($viddir."/".$file) && $file != "." && $file != "..") {
$d_arr[$d++] = $file;
// echo $file; //used for debugging
}
}
closedir($handle);
}
As long as $viddir is set, it works a treat, and the best bit is... the directories are in the order they were created (old at the start new at the end).
Now... I want to adapt this, but I'm not really sure how I'm gonna do this.
First, let me describe what I want. I need an array to be produced, but instead of one directy listing being used, I need two... but to make matters more complex, one directories will be on my server, while ther other directory will be on another ftp. To make things even harder, I need them to be arranged into the array in order of creation, so newer directories will be at the end of the array, and the oldest at the start.
Let me give an example:
directory listing on my server:
[FONT=courier new]Mar 05 05:01 directory43
Mar 24 05:06 videos
Mar 31 05:01 louise_rachel[/FONT]
and this is a directory listing on a remote ftp:
[FONT=courier new]Mar 10 01:04 new_dir
Mar 14 01:08 temp
Apr 03 01:04 sam[/FONT]
And I'll need the array to be in this order:
[FONT=courier new]$d_arr[1] directory43
$d_arr[2] new_dir
$d_arr[3] temp
$d_arr[4] videos
$d_arr[5] louise_rachel
$d_arr[5] sam[/FONT]
Now.. I'm pretty new to php, so I'm not really too sure quite how to do this... but could I somehow get directories AND thier creation dates into a multi-dimensional array, and then order the array by the creation date?