yeah, there are various ways of doing it... i'll explain what a couple of the functions do:
glob() - retrieves a list of all files in a directory by the supplied flags (* is everything) and returns them in an array
mt_srand() - seeds the better random number generator
mt_rand() - generates a number using the better random number generator [better version of rand()]
count() - returns the number of keys in an array, we use it in this instance to find the maximum array key so we can choose a random one. also see
sizeof()