How do you compare user Input to Array list?

I have the array list: $wordChoices = array(“soccerball”,"basketball ",“baseball”, “football”);
How do I see if what the user inputed is a valid guess in the array? This is what I have, and it doesn’t work.

} else if (in_array($_POST[‘myguess’], $wordChoices)){
$message = “Hey, that’s not even a valid guess. Try again”;
}
after
lets say baseball was the correct word. how do i compare that?
Thanks

my guess would the user input, is it a text box or a pull down box? if its a textbox, then change the in_array() to } elseif(in_array($_POST[‘myguess’], strtolower($wordChoices))) {, strtolower() changes the user input to all lowercase lettering. To php, there’s a literal difference between Php and php, its case sensitive in most cases.

Sponsor our Newsletter | Privacy Policy | Terms of Service