如何在数组中存储$ _FILES超全局变量并循环遍历它们以在PHP中找到匹配项?

I'm running if statements to identify each variable independently. My code is a bit messy and long but it works with no problem. I'd like to see if it is possible to use an array to store them and run a loop to see if there is a match, instead of using if statements.

PHP code...

if (move_uploaded_file($_FILES["index_deslizador_Cfile1"]["tmp_name"], $index_deslC1)) {
     echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Cfile2"]["tmp_name"], $index_deslC2)) {
     echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Cfile3"]["tmp_name"], $index_deslC3)) {
    echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Cfile4"]["tmp_name"], $index_deslC4)) {
    echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Mfile1"]["tmp_name"], $index_deslM1)) {
    echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Mfile2"]["tmp_name"], $index_deslM2)) {
    echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Mfile3"]["tmp_name"], $index_deslM3)) {
    echo "<script>window.open('../index.php','_self')</script>";
        }
else if (move_uploaded_file($_FILES["index_deslizador_Mfile4"]["tmp_name"], $index_deslM4)) {
    echo "<script>window.open('../index.php','_self')</script>";
        }                   
else {
    echo "Sorry, there was an error uploading your file.";
     }

I'm fairly new to PHP, so I may get scolded for this suggestion :) If you could get $index_deslC# variables into an array, you might be able to do something like this:

$i = 1
$destination = array($index_deslC...
foreach($_FILES["index_deslizador_Mfile" . $i]["tmp_name"] as $filename) {
    isset(move_uploaded_file($filename, $destination[$i]) ?
    echo "<script>window.open('../index.php','_self')</script>" : echo '';
    $i++;
}