when i want to check if a file exist and if exist add a suffix i use the following code which is working fine
$increment = ''; //start with no suffix
while(file_exists($_SERVER["DOCUMENT_ROOT"]."/".$file_name . $increment . '.' . $extension))
{
$increment++;
}
$final_name = $file_name . $increment. '.' . $extension;
Now i have to check if the file exist in more that one folder and the names of the folders are in an array (and i can add or remove folders from this array);
$folders[] = "thumb";
$folders[] = "medium";
$folders[] = "large";
$folders[] = "xlarge";
Now i have to check if the file exist in all these folders.
If the file exist in one of this folders i have to add a suffix check again until the file does not exist in all of these folders
Any help appreciated.