How would you loop through a list of 100 names to check that a certain entry is not one of those values in PHP?
I have a certain input that when the user enters a word in needs to be checked against a list of 100 words. How would I loop through th开发者_JAVA技巧ese words the easiest? Should I use a massive array?
If you don't care about case sensitivity or typos, this is the most straight-forward way:
$word = 'foo';
$wordList = array('foo', 'bar', 'baz', ...);
$wordIsInWordList = in_array($word, $wordList);
精彩评论