Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个特定的输入,当用户输入一个单词时,需要对照 100 个单词的列表进行检查。我将如何最简单地遍历这些单词?我应该使用一个庞大的数组吗?
如果您不关心区分大小写或拼写错误,这是最直接的方法:
$word = 'foo'; $wordList = array('foo', 'bar', 'baz', ...); $wordIsInWordList = in_array($word, $wordList);