Php - 表单验证 - 下拉菜单+评论框

I have been working on a input form for students for the past couple of hours. I have done mostly all of it with 0 hicups but I come across one minor issue that I can't think of a work around for. I have a drop down menu and the validation for that is :

 }
        if(empty($why) === true) {
            $errors[] = 'Please make sure to select the proper reasoning for your vistit today!';
    }

the default variable is set to be empty or just value="" (empty)...

now the next thing I need to validate is that if the student chooses the option "Other" I need them to then insert at least 10 characters and max of 30 into a Comments box specifically made for the students who can not find the general reason for their visit to the financial aid office. This is what I have for this (it is not working btw) :

if(isset($why) === Other) {
        $errors[] = 'Please add a comment explaining why you are visiting the office.';
}

So all in all I need help writing a validation that if the student chooses other then he or she MUST then write a brief summary as to why he or she is visiting the office in the "comments box".

Any help would be lovely. Thank you.

Lets say that the textarea for the 'other' field is called $other

if(empty($why)){
  $errors[] = 'Please select a reason';
}elseif($why == 'Other' && empty($other)){
  $errors[] = 'You selected Other. Please enter a reason why';
}

Your code will probably need to be more detailed than the above since you're looking to set a minimum and maximum number of characters, but you get the jist?

BTW, I see no reason why you would want to use the === operator instead of the == operator. They do the exact same thing but === checks to see if it's the same type, not sure what good this does for your script.

For if(isset($why) === Other), shouldn't Other be in quotes since $why will return the dropdown menu selection's value as text?

So if(isset($why) === 'Other') should work assuming that "Other" is the name of the dropdown menu's Other selection option.

Edit: Looking at your code again, you are comparing an isset() value to another var (Other). You want to have it as if(isset($why) && $why === 'Other') so this way you check that $why is set and it also equals the text "Other". The === operator is also checking to see if $why and Other are of the same type so you should check the rest of your code to make sure $why and Other are of same type.