The purpose of the script is to find the file in the array that is next AFTER $filename. I can find that value using:
$array[array_search($filename, $array) + 1]
but I also want to test whether the found file exists on my system, and if not, to test the one after that, and so on, until it finds a file that exists.
The current statement I have is:
if (!file_exists('/home/mysite.com/public_html/'.$array[array_search($filename, $array) + 1])) {
die("");
}
This tells the script to die if the found file isn't on my system, but I want it to cycle through the array until it finds one that does exist. (I then redirect the user to that page.)