i stumpted trying to make a script that gets a list of images in a directory and appends it to a .txt file so it looks like this (the text file):
image1.jpg image2.jpg image3.jpg image4.jpg ...
Check out the following:
http://www.php.net/manual/en/function.readdir.php
This instructs you on how to read the contents of a directory. Then you can read the file names into the text file or an array. You will probably have to do a few tests (as the manual states that the '.' and '..' files will be returned).
Hope this helps.