你将如何循环遍历100个名称列表以检查某个条目是否不是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 these words the easiest? Should I use a massive array?

我有一个输入,当用户输入一个单词时,需要根据100个单词的列表进行检查。 我怎样才能最简单地循环这些单词? 我应该使用大规模阵列吗? p> div>

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);