How can the use of if-else statements be optimized in PHP scripts, especially when dealing with multiple conditions for file type validation?

When dealing with multiple conditions for file type validation in PHP scripts, the use of if-else statements can be optimized by using a switch-case statement instead. This can make the code more readable and maintainable, especially when there are many file types to validate.

$fileType = 'pdf';

switch ($fileType) {
    case 'pdf':
    case 'doc':
    case 'docx':
        echo 'Valid file type';
        break;
    default:
        echo 'Invalid file type';
}