Forum Moderators: coopster
Then what is the container for the regexp match? So when replacing 'if' by 'while' to get all the image names, the following should come closer:
$buttons = new array[]; // ..or some constructor
$files = scandir('..');
while (preg_match('/^button\./', $files)) { /* add imagename to array $buttons */ }
What goes in the comments?
Thanks again
While it would still be useful to know how to get the regexp container for the match, the thread that is just following this one discusses the fact that PHP cannot do any client side scripting, which is exactly what I wanted it to do. So back to Javascript then, where I have no I/O functions, tough luck... Unless you know of some other option.
Best
Tech Nossomy
I've never used scandir because it's only available in PHP5, and I'm still using 4x. But if you're using PHP5 it looks like you could do something like:
$files = scandir('..');
$preload_images = "preloadImages("; //assumes preloadImages JS function
foreach($files AS $file) {
if (preg_match('/^button\./',$file)) $preload_images .= "'../$file',";
}
$preload_images = substr($preload_images,0,-1);
$preload_images .= ")"; ...then echo that in your body tag, like: onload="<? echo $preload_images?>", which is where I think you want it.
I hope this helps.