开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜