I'm trying to scan a directory and return a single specific folder,( the last one created)
This is for a photo website and I would like to use images from current weeks images for the header images without having to upload them to a rotator folder.
So here's where I'm at
$dir = './This/2013/Goes to specific class of race/';
$files1 = scandir($dir);
rsort($files1);
print_r($files1);
Returns all files in DESC order, including a photo.xml file generated by album builder,
Array ( [0] => photos.xml [1] => 09_01_2012 [2] => 08_25_2012 [3] => 08_18_2012....ect,ect
I want it to always ONLY return the NEWEST album folder, which in this example its ([1] => 09_01_2012) That's why I resorted into descending figuring the newest would always be on top of list.
But I can not figure out how to JUST GET that single folder.
____________________________________________________________
Then I need to access that NEWEST folder and randomly select a .jpg file form it.
If I manually insert the correct path I can get it to select a random file using this
[/size][/font][/color]
<?php
//path to directory to scan
$directory = "a/2013/direct/path/";
//get all files in specified directory
$files = glob($directory . "*");
//print each file name
foreach($files as $file)
echo $file;
}
}
?>
Above code with below code returns a random .jpg file, i CAN NOT GET THEM TO WORK COMBINED
[color=#000000][font='Times New Roman'][size=1] [/size][/font][/color]/<?php
// retrieve one of the options at random from the array
$file = $files[rand(0,count($files))];
print_r($file);
?>
I know very little about PHP, have done some CF coding but either way I hack my way through....
Any help or suggestions would be greatly appreciated, If you get me leaning the right direction, I can usually figure out the logic and complete it....
Hope I made sense to someone! LOL
Steve