Random image Ever wanted to know how to create the random gallery ? The same gallery as you can see on webclass.ru pages. Well, here is the way you can do it: " ); ?> Is it complicated ? Then let's comment the code. $handle = opendir( "path/to/image/dir" ); $imgArray = array(); Opens the folder where the images are stored and then empties the array of images. while($file = readdir($handle )) { if($file != "." && $file != "..") { array_push( $imgArray, $file ); } } closedir( $handle ); The code above starts a loop, reads folder contents and checks if the file is not a folder. Then a name of the file is stored in the array and folder is closed when the cycle is over. $randval = mt_rand( 0, sizeof( $imgArray ) - 1 ); This line generates a random value not greater than number of files in the directory. print( "" ); Last step is to print image tag code to the page.