Help with code to create an array from contents of folder
I recently upgraded a webpage using Ultimate Fade-in Slideshow script from version 1.5.1 to version 2.4. With the previous version I used a PHP script to build an array of photos from the contents of a folder. Here's the code (John, if you're reading this, I believe you gave me this code):
Code:
<?php
//call line: <script type="text/javascript" src="a/build_array.php?folder=b&array=c&usefilenames=d"></script>
// where a=relative location of the php script file
// b=relative location of graphics folder
// c=name of array to be built
// d=use file names as captions:yes|no
Header("content-type: application/x-javascript");
function returnimages($arrayname) {
$dirname="../" . $_GET["folder"] . "/";
$pathname="" . $_GET["folder"] . "/";
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
$curimage=0;
$str=',""';
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
if($_GET["usefilenames"]=='yes')
$str = ', "' . preg_replace('/\.[^\.]*$/', '', $file) . '"';
echo $arrayname . '[' . $curimage .']=["' . $pathname . $file . '", "", ""' . $str . '];' . "\n";
$curimage++;
}
}
closedir($handle);
}
}
$arrayname=$_GET["array"];
echo 'var ' . $arrayname . '=new Array();' . "\n";
returnimages($arrayname);
?>
The array name was then passed to the slideshow script as a parameter in the call.
The new slide show version has the array as an option:
Code:
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
["Graphics/ShowPics/100_0466-A.jpg"],
["Graphics/ShowPics/100_0467-A.jpg"],
["Graphics/ShowPics/100_0469-A.jpg"],
["Graphics/ShowPics/100_0470-A.jpg"],
["Graphics/ShowPics/100_0471-A.jpg"],
["Graphics/ShowPics/100_0472-A.jpg"]
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
What I'd like to do is replace the imagearray option and array definition with an array built by the PHP routine. I'm not a PHP coder, and really have no idea how to accomplish this.
Can someone please help me with this?
Thanks.