Forum Moderators: coopster
$array = array(
'file1.htm',
'file2.htm',
'file3.htm'
);
The script searches the array for a particular file ($filename), and returns the array value after that:
$array[array_search($filename, $array) + 1]
I need to test whether the new value is on my system, and if not, cycle through the array until I find one that is. I'm using this statement to test the condition:
if (!file_exists('/home/mysite.com/public_html/'.$array[array_search($filename, $array) + 1])) {
die("");
}
This tells the script to die if the next file after $filename isn't found, but I want it to cycle all the way through the array until it finds a file on my system. Cycle should start at $filename + 1 and start again at the beginning of the array if it reaches the end.
$start = array_search($currentpage, $array);
foreach ($array as $key => $value) {
if ($key > $start) {
if (file_exists('/home/mysite.com/public_html/' . $value)) {
header('location: [mysite.com...] . $value);
exit();
}
}
}
(This doesn't restart at the beginning when it reaches the end, but I've worked around that.)