Thanks to some help here I got this working awhile back to look at a file directory and pull out the names of images so I could do a display of random images. Now I would like to run it like a slide show and it seems like I need to hook it up to some javascript.
I found a javascript that does the slide show. It wants an array set up at the beginning called fadeimages - the format is like this:
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["Boat Roll Des Oct 06.jpg", "", ""] //plain image syntax
fadeimages[1]=["DSCN0459.jpg", "", ""]
fadeimages[2]=["Group 10-06.jpg", "", ""]
fadeimages[3]=["IMGP0196.jpg", "", ""]
fadeimages[4]=["IMGP0223.jpg", "", ""]
fadeimages[5]=["IMGP0237.jpg", "", ""]
So I have some PHP code that pulls the array of photos like this:
function file_type($file)
{
$path_chunks = explode("/", $file);
$thefile = $path_chunks[count($path_chunks) - 1];
$dotpos = strrpos($thefile, ".");
return strtolower(substr($thefile, $dotpos + 1));
}
$path = "assets/web_imgs/";
$file_types = array('jpeg', 'jpg', 'ico', 'png', 'gif', 'bmp', 'html');
$p = opendir($path);
while (false !== ($filename = readdir($p)))
{
$files[] = $filename;
}
sort($files);
foreach ($files as $file)
{
$extension = file_type($file);
if($file != '.' && $file != '..' && array_search($extension, $file_types) !== false)
{
$file_count++;
$picturesArray[] = $file;
}
}
So what I am wondering is how can I have it pass the array from the PHP -- $picturesArray[] into the Javascript array "fadeimages"
Is it doable?