Just use a foreach to iterate the array:
$required = array('header.php', 'footer.php', 'sidebar.php', 'info.php');
foreach ($required as $required) {
if (!file_exists($required)) {
die('Please upload files properly');
}
}
Edit It’s not a mistake that I used the same variable for the array items as for the array itself. foreach uses an internal copy of the array and not the array itself:
Note: Unless the array is referenced, foreach operates on a copy of the specified array and not the array itself. foreach has some side effects on the array pointer. Don't rely on the array pointer during or after the foreach without resetting it.
Although the original array in $required overwritten with the first iteration, the internal one stays as initially passed to foreach. This might not be best practice since it’s a little confusing when not known. But it’s absolutely valid.