I am using the following code to loop through the filenames of a folder and add them into a javascript array for use in my slideshow. This works fine, but once the first loop displaying the images is finished, it sends the site into an endless loop tryinh to download the files..
servername/css/loader-1.png
servername/css/loader-2.png ... etc all the way upto servername/css/loader-11.png
Which are the files that are used by the slideshow.
Code: Select all
<?php
$addarray = array();
$x = 0;
if ($handle = opendir('slideshow')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$file_name=substr($file, 0, strpos($file, "."));
if ( $file_name != "")
{
$addarray[$x] = "$file_name.jpg";
$x = $x + 1;
}
}
}
}
closedir($handle);
?>
<script type="text/javascript">
//<![CDATA[
window.addEvent('domready', function(){
var data =new Array("<?=implode("\",\"", $addarray); ?>")
// Initialize the Slideshow instance
var myShow = new Slideshow('show', data, { height: 240, hu: 'images/', width: 300 });
});
//]]>
</script>Thanks
Tom