Losowe foto z różnych folderów

Wiem, że było już kilka podobnych tematów przeczytałem je ale nie mogłem znaleźć odpowiedzi na moje pytanie na strone wgrałem taki skrypt:

<?php

/* Customise this line to change to your images folder */

$dir = 'foty/'; $dh = opendir($dir);

/* The following loop scans the directory specified ignoring folders and Thumbs.db */

while (false !== ($filename = readdir($dh))) { if($filename == "Thumbs.db" || 


is_dir($filename)){ }else{ $tempArray = explode(".", $filename);

/* Add image file types in the code below */ if($tempArray[1] == "JPG" || $tempArray[1] == 


"gif" || $tempArray[1] == "png" || $tempArray[1] == "tif" || $tempArray[1] == "bmp"){ 


$files[] = $filename; } } }

/* Generate a random number */ $nooffildi = count($files); $nooffiles = ($nooffildi-1); 


srand((double)microtime()*1000000); $randnum = rand(0,$nooffiles);

/* print the result */echo "


HEIGHT='150'>"; ?>[/code]

Wszystko działa ale nie mogę go przerobić tak by pobierało zdjęcia z kilku folderów a nie tylko z foty. Był bym bardzo wdzięczny jeśli by ktoś był tak uprzejmy i przerobił mi ten skrypt

<?php


// zmienna $losowy_fol jest odpowiedzialna za losowe wybranie folderu

$losowy_fol = rand(1,3);

// wklepujesz sobie nazwy folderow z ktorych ma byc pobrane zdjecie

$foldery_fotki = array(	"1" => "fotki",

				  "2" => "fotki2",

				  "3" => "fotki3", );


$dir = $foldery_fotki[$losowyfol];


/* Customise this line to change to your images folder */

$dh = opendir($dir);

/* The following loop scans the directory specified ignoring folders and Thumbs.db */

while (false !== ($filename = readdir($dh))) { if($filename == "Thumbs.db" ||


is_dir($filename)){ }else{ $tempArray = explode(".", $filename);

/* Add image file types in the code below */ if($tempArray[1] == "JPG" || $tempArray[1] ==


"gif" || $tempArray[1] == "png" || $tempArray[1] == "tif" || $tempArray[1] == "bmp"){


$files[] = $filename; } } }

/* Generate a random number */ $nooffildi = count($files); $nooffiles = ($nooffildi-1);


srand((double)microtime()*1000000); $randnum = rand(0,$nooffiles);

/* print the result */echo "


HEIGHT='150'>"; ?>

[/code]

Nie sprawdzałem czy działa.

Pozdrawiam

niestety ale nie chce działać

działa jak zmienisz [$losowyfol] na [$losowy_fol]

<?php 


// zmienna $losowy_fol jest odpowiedzialna za losowe wybranie folderu 

$losowy_fol = rand(1,3); 

// wklepujesz sobie nazwy folderow z ktorych ma byc pobrane zdjecie 

$foldery_fotki = array( "1" => "fotki", 

              "2" => "fotki2", 

              "3" => "fotki3", ); 


$dir = $foldery_fotki[color=red][$losowy_fol][/color]; 


/* Customise this line to change to your images folder */ 

$dh = opendir($dir); 

/* The following loop scans the directory specified ignoring folders and Thumbs.db */ 

while (false !== ($filename = readdir($dh))) { if($filename == "Thumbs.db" || 


is_dir($filename)){ }else{ $tempArray = explode(".", $filename); 

/* Add image file types in the code below */ if($tempArray[1] == "JPG" || $tempArray[1] == 


"gif" || $tempArray[1] == "png" || $tempArray[1] == "tif" || $tempArray[1] == "bmp"){ 


$files[] = $filename; } } } 

/* Generate a random number */ $nooffildi = count($files); $nooffiles = ($nooffildi-1); 


srand((double)microtime()*1000000); $randnum = rand(0,$nooffiles); 

/* print the result */echo " 


HEIGHT='150'>"; ?>[/code]