[英]How to loop through a list of variables and check if their values is not empty in php
[英]How would you loop through a list of 100 names to check that a certain entry is not one of those values in PHP?
我有一个确定的输入,即当用户输入一个单词时,需要对照100个单词的列表进行检查。 我将如何最轻松地遍历这些单词? 我应该使用大量数组吗?
如果您不关心区分大小写或错别字,这是最简单的方法:
$word = 'foo';
$wordList = array('foo', 'bar', 'baz', ...);
$wordIsInWordList = in_array($word, $wordList);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.