I am new to PHP as well, but I'll try to answer your question based on my reading in the manual.
In the beginning of the script you'll see the line below. This line basically declares the directory "thumbs" to the variable $thumbs. It is the location of the directory (pretty self-explanatory).
$thumbs = "thumbs/"; # Location of thumbnail
This line declares the variable $handle to open the directory $thumbs. opendir is a function that opens up a directory for use with several functions: resource opendir ( string path [, resource context] ). In this case it does opendir($thumbs) where string path is $thumbs.
if ($handle = opendir($thumbs)) {
Ok, this is a while loop. Readdir is again, part of PHP (built-in). What purpose does it serve? It simply returns the filename of the "next most" file in the directory if successful. OTHERwise it returns a value of false. If you have 2 files, JessicaAlba.jpg and KieraKnightley.jpg, it will output both of the thumbnails on the page. As long as it doesn't return false, it'll go along with the loop (meaning as long as it's successful the script will execute."
while (false !== ($file = readdir($handle))) {
Ok, I can sum these few lines up together. If the file name your trying to open begins with a . or .. then it won't display, otherwise, everything else will go into the array files.
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($handle);
}
And files, later in the program, is displayed in a foreach loop (new in later versions of PHP). If you need any extensive information on this, I suggest visiting the manual at PHP.net.