Thanks.
The code:
<?php
if ($handle = opendir('./img')) {
$count = 0;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
print 'fadeimages['.$count.']=["'.$file.'", "", ""]';
$count++;
}
}
closedir($handle);
}
?>
Outputs:
fadeimages[0]=["strawberry.jpg", "", ""]fadeimages[1]=["red pepper.jpg", "", ""]fadeimages[2]=["rasberry.jpg", "", ""]fadeimages[3]=["potatoes.jpg", "", ""]fadeimages[4]=["orange sky.jpg", "", ""]fadeimages[5]=["old onions.jpg", "", ""]fadeimages[6]=["lemon.jpg", "", ""]fadeimages[7]=["kiwi fruit.jpg", "", ""]
There are two elements preventing the images from showing.
The formatting of the array, each item needs to be on it own line - I have tried inserting a line feed but it just gets printed into the array!
The dhtml script doesn't know that the images are in the folder img/
I tried to add the folder img/ to the line:
print 'fadeimages['.$count.']=["'img/.$file.'", "", ""]';
Though I get parse errors.
I would prefer to just drop the script into the same folder as the images, though the script also gets fed into the array! Is there a way to filter anything but .jpg, .gif and .png? I guess through regex.