I do think you need to get yourself a book (e- or otherwise) and start from the basics, PHP is a scripting language, and as such is USUALLY run from the top down to the bottom (there are a few exceptions)
PHP Code:
if ($handle = opendir($images)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
$files[] = $file;
}
}
closedir($handle);
}
Is where the $files array is generated, one key at a time, so trying to operate on that array before it has been actually initialised obviously will not work, you can put the sort function any time after that.